Deleriux
02-23-2003, 10:44 AM
This is probably a simple one, ive had look around for an answer on here but thres lots of other results that are nothing to do with what i want, a brief google search doesnt return much either.
Ive wrote a script that updates my router ip address to the dynamic dns service, all was well and good for a few weeks, until they banned me for abuse :-\.
I had the script updating every 30 minutes reguardless of it being the same ip or not, obviously they didnt like it so they banned me.
So, i thought 'ok fair enough ill simply write a scirpt that checks my ip locally to what it was 30 minutes ago, if its different ill get it to update if its the same it doesnt do anything.
what i have is two simaler scripts that do the simaler jobs, one is called showip, this displays my router address to my console, the other is called getip, this returns the address to a dynamic dns updater which gives it to the dynamic dns server.
What i have basically go going here is..
$OLDIP=$CURENTIP
showip>temp
$CURRENTIP=$(cat temp)
if [ "$OLDIP" != "$CURRENTIP"]; then
getip
my problem is this, this local update needs to be run every 30 minutes, so i need to keep $CURRENTIP in the list of permanent variables (like $PATH for example). From what i can gather, variables are all temporary within the script and then they are trashed.
'Fair enough' i thought, ill use export, so i did:
export CURRENTIP
and also tried:
export CURRENTIP=$CURRENTIP
i put this at the end of the script, therefore i always have the ip address for the next time the check runs after 30 minues.
But this doesnt work, if i do echo $CURRENTIP in my console i get returned nothing?!
So, my question is, how do i get a shell variable and make it permenment, even if the script finishes or a close down the console?
Ive wrote a script that updates my router ip address to the dynamic dns service, all was well and good for a few weeks, until they banned me for abuse :-\.
I had the script updating every 30 minutes reguardless of it being the same ip or not, obviously they didnt like it so they banned me.
So, i thought 'ok fair enough ill simply write a scirpt that checks my ip locally to what it was 30 minutes ago, if its different ill get it to update if its the same it doesnt do anything.
what i have is two simaler scripts that do the simaler jobs, one is called showip, this displays my router address to my console, the other is called getip, this returns the address to a dynamic dns updater which gives it to the dynamic dns server.
What i have basically go going here is..
$OLDIP=$CURENTIP
showip>temp
$CURRENTIP=$(cat temp)
if [ "$OLDIP" != "$CURRENTIP"]; then
getip
my problem is this, this local update needs to be run every 30 minutes, so i need to keep $CURRENTIP in the list of permanent variables (like $PATH for example). From what i can gather, variables are all temporary within the script and then they are trashed.
'Fair enough' i thought, ill use export, so i did:
export CURRENTIP
and also tried:
export CURRENTIP=$CURRENTIP
i put this at the end of the script, therefore i always have the ip address for the next time the check runs after 30 minues.
But this doesnt work, if i do echo $CURRENTIP in my console i get returned nothing?!
So, my question is, how do i get a shell variable and make it permenment, even if the script finishes or a close down the console?