newbie needs a little help... trying to write an ftp script.

Wojtek Walczak gminick at hacker.pl
Tue Jul 29 09:49:12 CEST 2003


Dnia 28 Jul 2003 11:40:48 -0700, google account napisał(a):
[...]
> The docs suggest that I could do something like....
> 
> import ftplib
> 	
> ftp = ftplib.FTP('172.30.30.30')  # This is wrong,  somehow...?
> ftp.login(user,pass)
                 ^^^^
Do not use pass in this way - it's a python's keyword. Use some other 
name instead.

> ftp.retrlines('LIST')  # I believe it might need to be
> ftp.retrlines('ls -al')
> ftp.sendcmd('prompt')
> ftp.cwd('folder')
> ftp.retrbinary(retr *tgz)
> ftp.quit()
Here's a simple example:

import ftplib,sys

ftp = ftplib.FTP('ftp.python.org')
ftp.login('anonymous','qwe at asd.pl')
print ftp.retrlines('LIST')
ftp.cwd('pub/python')
print ftp.retrlines('LIST')
print ftp.retrbinary('retr README', sys.stdout.write)
ftp.quit()

-- 
[ Wojtek Walczak - gminick (at) underground.org.pl ]
[        <http://gminick.linuxsecurity.pl/>        ]
[ "...rozmaite zwroty, matowe od patyny dawnosci." ]





More information about the Python-list mailing list