Computing.Net > Forums > Unix > script to check a dynamic ip

script to check a dynamic ip

Reply to Message Icon

Original Message
Name: wolf60s
Date: August 31, 2004 at 17:27:25 Pacific
Subject: script to check a dynamic ip
OS: solaris 8 intel
CPU/Ram: p4/256
Comment:

Hi, I need a shell script to check a dynamic ip(from cable company), it will send the ip to my email if the ip changes. The Solaris box is behind the router with a static ip (internal), the router connected with a cable modem for internet connection. The problem is the cable company assigned you a dynamic ip, and it changes sometime. When that happens, I can't not access my Solaris box outside my home. On the local box I can know my current external ip through the http://checkip.dyndns.org/. How can I write that in a script to send the ip to my email if it changes? I'm using Bourne shell.


Report Offensive Message For Removal

Response Number 1
Name: David Perry
Date: September 1, 2004 at 10:24:26 Pacific
Subject: script to check a dynamic ip
Reply: (edit)

http://www.computing.net/solaris/wwwboard/forum/4287.html

NEWIP=`lynx --dump http://checkip.dyndns.org`
if [ `cat iplogfile` != "$NEWIP" ] ; then
echo "My new IP address is $NEWIP" | mail user@domain.com
echo $NEWIP > iplogfile
fi


Report Offensive Follow Up For Removal

Response Number 2
Name: wolf60s
Date: September 1, 2004 at 16:37:49 Pacific
Subject: script to check a dynamic ip
Reply: (edit)

Thanks so much for your help. I copied the script(only change is the email address) to my solaris box and saved as ipcheck. I tried to run it, and following is the output.

# ./ipcheck
./ipcheck: lynx: not found
./ipcheck: syntax error at line 3: `then' unexpected
#

Please let me know if there is anything need to be fixed. Thanks. -wolf


Report Offensive Follow Up For Removal

Response Number 3
Name: Dudley
Date: September 5, 2004 at 15:27:21 Pacific
Subject: script to check a dynamic ip
Reply: (edit)

I dont think Solaris come with lynx installed, you should be able to download it from http://www.sunfreeware.com/


Report Offensive Follow Up For Removal

Response Number 4
Name: wolf60s
Date: September 8, 2004 at 16:33:12 Pacific
Subject: script to check a dynamic ip
Reply: (edit)

Thanks for your help. I installed lynx and ran script. Following is the output. Please let me know any changes needed. Thanks again.

# ./ckip
ld.so.1: lynx: fatal: libncurses.so.5: open failed: No such file or directory
./ckip: NEWIP: not found
./ckip: syntax error at line 2: `|' unexpected


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: script to check a dynamic ip

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software