ftplib question

lc lco at gofuse.com
Wed Aug 8 16:13:15 EDT 2001


I'm a beginner and am trying to use the ftplib module to automate an ftp
process. I"m using the following code...
--------------------------------------------------------
import ftplib
import os

def upload(ftp, file):
    ext = os.path.splitext(file)[1]
    if ext in (".txt", ".htm", ".html"):
        ftp.storlines("STOR " + file, open(file))
    else:
        ftp.storbinary("STOR " + file, open(file, "rb"), 1024)

ftp = ftplib.FTP("ftp.fbi.gov")
ftp.login("mulder", "trustno1")

upload(ftp, "trixie.zip")
upload(ftp, "file.txt")
upload(ftp, "sightings.jpg")
----------------------------------------------------------
Question#1 : I'm not sure how i can change to the directory i want to upload
the files to. Any help would be appreciated.
Question#2 : does anyone know of a python module that allows me to schedule
tasks?
TIA
lc






More information about the Python-list mailing list