[Tutor] ftplib error
Kent Johnson
kent37 at tds.net
Wed Feb 22 18:08:03 CET 2006
benmarkwell at gmail.com wrote:
> I'm trying to write a backup script to put files on a server.
>
> --This is how I have begun:
>
>
> from ftplib import FTP
>
> f = open(r'g:\dev\python\exercises\aaa.py', 'r')
> fname = r'g:\dev\python\exercises\aaa.py'
>
> ftp = FTP('ftp.xxxx.com <http://ftp.xxxx.com>')
> ftp.login()
>
> ftp.storlines ('STOR ' + fname, f)
fname should be just a bare name, e.g. 'aaa.py'. You have to ftp.cwd()
to the correct directory yourself.
Here is a module I use for ftp upload, it has a nicer API than the bare
ftplib:
http://www.nedbatchelder.com/code/modules/ftpupload.html
Kent
More information about the Tutor
mailing list