PDA

View Full Version : Make Tivo over the Internet



Mike Sharkey
02-05-2007, 10:08 AM
Hi All,

I am using the HowTo:PasswordProtectedRemoteAccess and I have created the file dyndns.sh, placed it in the /var/hack directory and made it executable.
When I try to test it I get:
[TiVo [p0] ~]# ./dyndns.sh
bash: ./dyndns.sh: No such file or directory
[TiVo [p0] ~]#

I get the same if I put in the path:
[TiVo [p0] /]# /var/hack/dyndns.sh
bash: /var/hack/dyndns.sh: No such file or directory
[TiVo [p0] /]# cd /var/hack
[TiVo [p0] /var/hack]# dyndns.sh
bash: dyndns.sh: command not found

The file is there and the permissions are OK.

[TiVo [p0] ~]# find /var/hack/dyndns.sh
/var/hack/dyndns.sh
[TiVo [p0] ~]# cd /var/hack
[TiVo [p0] /var/hack]# ls -l dyndns.sh
-rwxr-xr-x 1 0 0 854 May 2 10:32 dyndns.sh

The first line of the file is: #!/bin/sh
so I don't think that's the problem.

To create the file I simply copied & pasted from the HowTo to a new file in xint. I modified the Host Name etc and saved it as dyndns.sh

I am not very experienced in Linux so I would be grateful if anyone could point out the error of my ways!

Regards
Mike Sharkey

Phillips Series 1 Tivo running v.1.5 Image

catdog
02-05-2007, 11:35 AM
Taking a guess here - did you create the file on a windows machine? (or ftp in ascii mode?)

you probably need to run:
dos2unix dyndns.sh
chmod 755 dyndns

then try again

Mike Sharkey
02-05-2007, 12:44 PM
You are spot on....I did create the file on a Windows PC, so I did what you suggested and I got the file to execute. Thank you for that.

I found I had to change some of the paths in the file location section of dyndns.sh (/devbin instead of /hack/bin).
Now I get to the part where it's supposed to get my IP address and it falls over.
[TiVo [p0] /var/hack]# /var/hack/dyndns.sh
--13:34:44-- http://www.myipaddress.com/
=> `index.html'
Resolving www.myipaddress.com... failed: Host not found.
grep: index.html: No such file or directory
rm: indexhtml: No such file or directory
/bin/cat: /tmp/ip.txt: No such file or directory

I don't believe the router (Netcomm NB1300PLUS4) is a problem as the Tivo makes the daily call OK.

Any thoughts?

MattCallow
02-05-2007, 03:21 PM
It looks to me like you don't have a nameserver setup on your tivo. Either edit /etc/resolv.conf and add your ISPs nameserver or change the dyndns.sh script to use the ip address of www.myipaddress.com instead of the host name.

My /etc/resolv.conf contains:


# Example resolv.conf file
# ns.optus.net.au:
nameserver 61.88.88.88

Mike Sharkey
03-05-2007, 11:52 AM
Thanks Matt, you were right. I edited the dyndns.sh file replacing the Host Name with the IP address (although I had to go away from www.myipaddress.com as they seem to have introduced a security feature which prevented the script working). Anyway I used http://checkip.dyndns.com (204.13.249.51) and it worked......up to a point!

There was another Host Name in the script (http://members.dyndns.org/nic etc) which it uses to update the IP database. When I set about trying to find the IP address for this site I came across an announcement from dyndns.com dated April 2003 to the effect that members 'NIC' was being retired.

"For the forseeable future, links within members.dyndns.org will be automatically redirected to the new locations within www.dyndns.org, but please be sure to update any bookmarks pointing to members.dyndns.org appropriately. Update clients should continue to use members.dyndns.org, not www.dyndns.org, to perform updates." (http://www.dyndns.com/news/releases/members_nic_retired.html)

So now I'm stumped again!

As before, grateful for any suggestions :)

MattCallow
03-05-2007, 12:57 PM
According to the the Dyndns API https://www.dyndns.com/developers/specs/syntax.html , members.dyndns.org is the correct host to use.
What problems are you seeing now?
I would recommend at this stage that you update /etc/resolv.conf to contain a valid nameserver. To do this enter the following commands on the tivo (you can copy and paste everything inside the blue box)


rw
cp /etc/resolv.conf /etc/resolv.conf.bak
echo "nameserver 61.88.88.88" >> /etc/resolv.conf
ro
cat /etc/resolv.conf
ls -l /etc/resolv.conf*

Please post the output of the above commands

Mike Sharkey
03-05-2007, 01:35 PM
All is well!
I should have read your first post more carefully, Matt.
I followed your first suggestion and edited the resolv.conf file to include the Bigpond nameserver and the script worked perfectly (including the www.myipaddress.com lookup)

I have put the line 15,45 * * * * /var/hack/dyndns.sh into /hack/etc/crontab..............I presume that's the place for it?

Thanks for all your help

MattCallow
03-05-2007, 02:09 PM
I have put the line 15,45 * * * * /var/hack/dyndns.sh into /hack/etc/crontab..............I presume that's the place for it?

I guess that will work (not tried it myself) but it may get overwritten if you update your tivo.
May be better move that line to a new file in /hack/etc/cron.d ?

Mike Sharkey
03-05-2007, 02:45 PM
I just checked the execution again and I noticed it ran the full script even though my IP address had not changed.
Looks to me as if the comparison of old and current IP is not working.
Is there a way that I can check the value of OLDIP=`$CAT $CACHE`?

MattCallow
03-05-2007, 02:56 PM
Assuming your using the script from the wiki

cat /tmp/ip.txt

You may also like to try

sh -x ./dyndns.sh
which will show the output of each command as it's run

Mike Sharkey
03-05-2007, 03:54 PM
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.

MattCallow
03-05-2007, 05:18 PM
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

IP=`$GREP 203 index.html |$SED 's/<p><b>//g' | $SED 's/<\/b>//g'`
to

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

IP=`$GREP "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" index.html |$SED 's/<p><b>//g' | $SED 's/<\/b>//g'`

Mike Sharkey
03-05-2007, 06:17 PM
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?

MattCallow
04-05-2007, 08:48 AM
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



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)

Mike Sharkey
04-05-2007, 10:04 AM
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.

MattCallow
04-05-2007, 10:24 AM
Good! Glad it works. I've uploaded a modifed version of the script to the WiKi page

ciper
16-08-2007, 12:55 AM
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/showthread.php?t=51840