Click to See Complete Forum and Search --> : Help with exort or the command that does what i want :)


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?

Deleriux
02-23-2003, 10:51 AM
scrub that :) i cracked it.

i just dont delete the temp file after showip.

that way i can assign it with the old ip address before updating.
Not exactly what i want to do. but, nevertheless it works.

bwkaz
02-23-2003, 02:13 PM
If you're using DynDNS or anything compatible with them, they (www.dyndns.org) have a whole ton of client programs that will do what you want with no scripting from you...

Deleriux
02-23-2003, 06:46 PM
yeah, thanks ive actually got one, called updatedd.

Command line client, unfortunately its not a daemon or anything special, just a command line that passes arguments onto dyndns.org.

So i have to write a script to sucessfully accomplish updates at intervals.

The reason i cant use a normal daemon type program is because my router stores my WAN address. If a daemon was to check my ip it would always return a LAN address. Thats the reason i deliberately chose a command line client so customised editing could be done within a script to sort through the messy html from the router and grep the ip address.

bwkaz
02-23-2003, 09:10 PM
Doesn't ddclient support pulling your public IP from a whole ton of routers?

See if yours is on the list:

http://clients.dyndns.org/unix.php

It's the first one there, and it's the one I'll use later on if I end up getting DSL (but then again, I won't use a router either; I'll do the NAT myself).