-
Here' s what I get:
+ OLDIP=<tr height=60 align=center valign=top> <td height=60 align=center> 60.228.7.242 <tr height=60> <td height=60 align=center> <tr height=60 align=center valign=bottom> <td height=60 align=center>
+ '[' '<tr height=60 align=center valign=top>
<td height=60 align=center>
60.228.7.242
<tr height=60>
<td height=60 align=center>
<tr height=60 align=center valign=bottom>
<td height=60 align=center>' '!=' '<tr height=60 align=center valign=top> <td height=60 align=center> 60. 228.7.242 <tr height=60> <td height=60 align=center> <tr height=60 align=center valign=bottom> <td height= 60 align=center>' ']'
+ /devbin/wget
So even though IP and OLDIP seem to be the same, it goes on to the next line (wget) when I think it should just exit.
-
Hmm, the problem is that the script expects your IP to start with 203, but yours starts with 60.
Therefore your old/new IP is a whole load of html not just the IP
Try changing the script
Code:
IP=`$GREP 203 index.html |$SED 's/<p><b>//g' | $SED 's/<\/b>//g'`
to
Code:
IP=`$GREP 60 index.html |$SED 's/<p><b>//g' | $SED 's/<\/b>//g'`
Or maybe you've already done that? Because you are getting every bit of html that contains the number 60.
In which case try changing it to
Code:
IP=`$GREP "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" index.html |$SED 's/<p><b>//g' | $SED 's/<\/b>//g'`
-
Well done, that did the trick!
I had already changed 203 to 60 but never twigged that it was picking up character sizes as well. In any event your solution is better because I see now that Bigpond IP addresses sometimes start with 203.
The script works fine now, although it still picks up some of the HTML code
[TiVo [p0] /tmp]# cat /tmp/ip.txt
<html><head><title>Current IP Check</title></head><body>Current IP Address: 203. 51.17.173</body></html>
Is this what you would expect?
-
That's because you are using checkip.dyndns.com rather than www.myipaddress.com.
The script is designed to parse the output from www.myipaddress.com. In fact checkip.dyndns.com is probably easier to use.
I expect that what you have now will work fine, but if you want a really tidy output from checkip.dyndns.com you could try
Code:
CUT=/devbin/cut
IP=`$CUT -d: -f2 < index.html | $SED -e :a -e 's/<[^>]*>//g;/</N;//ba' -e 's/^[ \t]*//;s/[ \t]*$//'`
This uses cut to split the text at the ':', then sed to remove the html tags and leading/trailing whitespace
(sed scripts from http://www.eng.cam.ac.uk/help/tpl/unix/sed.html)
-
That worked perfectly!
++ /devbin/sed -e :a -e 's/<[^>]*>//g;/</N;//ba' -e 's/^[ \t]//;s/[ \t]*$//'
+ IP=203.51.17.173
Thank you for all your help. You have expanded my knowledge and once again demonstrated what a great forum this is.
-
Good! Glad it works. I've uploaded a modifed version of the script to the WiKi page
-
Take a look at the script I created. You might prefer it over the script you are currently using. It doesnt require the username and password in cleartext and will keep activity on your DynDNS account so it isn't deleted.
http://www.dealdatabase.com/forum/sh...ad.php?t=51840