[Tutor] python and cron

Andy Kim reveranddaddy@yahoo.com
Wed Feb 19 12:46:02 2003


Timothy,

I know you are trying to use Python for this problem,
but a better solution might be to use dhs.org.
What you need to sign up for is dynamic dns.
You choose a server name and everytime you get a new
ip address you tell dhs the new ip address and they
update their dns entry. So the effect is you can ssh
and ftp into myserver.dhs.org.
They used to do this for free, but I think they will
charge you a minimal fee now.
Go check it out at:
http://www.dhs.org/support/dynamic.shtml

- Andy

--- "Timothy M. Brauch" <tbrauch@mindless.com> wrote:
> I am having a problem, and I'm not sure if it is
> with Python or cron.
> 
> I have a dynamic IP address for my home computer. 
> Every time I connect, I
> get a new IP.  My connection is not the best, and
> sometimes I am only
> connected for an hour, sometimes a day.  My machine
> automatically
> reconnects, so it's not a big deal.  However, I
> would like to know my IP so
> I can ssh or ftp.
> 
> I wrote a small Python script to check my IP.  I
> would like for this script
> to run every hour.  I thought a cron job would be
> perfect, but it does not
> seem to work.  I checked my log and there are no
> errors and I don't get any
> errors emailed to me.  The script works fine from
> command line.
> 
> Here is part of my code:
>
--------------------------------------------------------------
> #! /usr/bin/python
> import urllib, ftplib, re, time
> 
> ##Get the IP address from the router:
> source =
>
urllib.urlopen('http://192.168.xxx.xxx/st_devic.html')
> info = source.read()
> source.close
> 
> ##Clean up any HTML coding
> data = re.sub('<.*>|&nbsp;','',info).split()
> 
> ##The IP address is in field 29
> address = data[29]
> 
> ##here is the html formatting stuff for the
> published webpage.
> 
> ##Write the formatted stuff to a file
> formatted = open('ip.html', 'w')
> formatted.write(html)
> formatted.close()
> 
> ##Open the file and ftp it so I someone can get my
> IP
> new_file = open('ip.html', 'r')
> 
> ftp =
> ftplib.FTP('ftp.domain.com','login','password')
> ftp.cwd('private')
> ftp.storbinary('STOR index.html', new_file)
> ftp.quit()
> new_file.close()
>
-----------------------------------------------------------------
> 
> Here is the entry from crontab:
>
-----------------------------------------------------------------
> 0 * * * * /var/ftp/getipaddress.py
>
-----------------------------------------------------------------
> 
> All of this is owned and run by root, so it
> shouldn't be permissions.
> 
> Can someone offer some help?
> 
>  - Tim
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com