Why does my ftp script quit after couple of hours?

Diez B. Roggisch deets at nospam.web.de
Fri Aug 14 12:17:57 EDT 2009


kk schrieb:
> Hi
> This way the first time I did something with ftp stuff. I think that
> generally it works but it stops working(quits or disappears) after
> couple of hours of running.
> 
> This was a personal test-trial script for my own needs which was to
> get my dynamic ip and broadcast to a client(I have a client script on
> another computer). I sure could use something like DynDns for the same
> purpose with easier management but I just wanted to give it a try to
> see if i could even make it work .
> 
> Basically this script parses my ip from DynDns ip check page and
> uploads it to the given ftp site. It works fine initially, it does
> upload, it updates the Ip every hour but the problem is that after
> couple of hours the Python console window disappears, I assume it
> crashes.  I know it does upload at least couple times(works for couple
> hours). it might be something to do with ftp connection. I will
> investigate that but I just wanted to see if I have any logic or some
> kind of contextual problem in the script.
> 
> 
> Here is the link to Pastie page
> http://pastie.org/584152


The code isn't very robust if anything happens retrieving the IP-website 
- if for some reason the connection is broken, it won't catch any 
ensuing IO-exception.

Also your way of extracing the IP is rather awkward, a simple re (often 
not the right tool, but here certainl yes) would help:

 >>> m = re.search(r"(([0-9]+\.){3}[0-9]+)", body)
 >>> m.group(1)
'85.177.92.101'
 >>>


Diez



More information about the Python-list mailing list