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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

script to check a dynamic ip

Reply to Message Icon

Name: wolf60s
Date: August 31, 2004 at 17:27:25 Pacific
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.



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: September 1, 2004 at 10:24:26 Pacific
Reply:

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


0

Response Number 2
Name: wolf60s
Date: September 1, 2004 at 16:37:49 Pacific
Reply:

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


0

Response Number 3
Name: Dudley
Date: September 5, 2004 at 15:27:21 Pacific
Reply:

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


0

Response Number 4
Name: wolf60s
Date: September 8, 2004 at 16:33:12 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: script to check a dynamic ip

shell script to check for a file on www.computing.net/answers/unix/shell-script-to-check-for-a-file-on/3714.html

A script to telnet a service www.computing.net/answers/unix/a-script-to-telnet-a-service/6542.html

Shell script to read a file and pro www.computing.net/answers/unix/shell-script-to-read-a-file-and-pro/4304.html