I want to do something:

Jeremy Moles xione at bellsouth.net
Sat Jul 28 12:24:37 EDT 2001


I want to do something every minute, but I also want the program to have a
small footprint. Does anyone have any advice? This is the code I have so
far:

import socket
import ftplib
x=socket.gethostbyname(socket.gethostname())
y=open('D:\\Python\\IP.html','w')
y.write(x)
y.close()
z=ftplib.FTP(host='softwherecompany.com')
z.login(user='john',passwd='doe')
z.cwd('public_html')
z.storlines('STOR IP.html',open('D:\\Python\\IP.html','r'))
z.close()

Basically, what this code does is get my IP address and upload it to my
webserver - since my IP is dynamic, and I never quite know what it is when I
leave this house.

But anyways - how can I do this - say - every minute or so? Could I:

import time

while(time.time()%60==0):
    do_my_function()

Also - I'd like to get rid of the temporary file in my code. You'll notice
that I had to create "y" so that it could be uploaded. Is there any way just
to write to a file on an ftp server with python without actually UPLOADING
an existing file?

Do I make any sense? =)






More information about the Python-list mailing list