Connect to FTP

foo bar sofstouki at
Fri Feb 25 15:37:45 CET 2011

Hi all, 
I am trying to put together a script (Python 2.5, windows xp) that connects to an ftp server and retrieves/uploads files.
I am sure what I have put together is completely insufficient and I get the errors:
Traceback (most recent call last):
  File "C:\Documents and Settings\\Desktop\", line 19, in <module>
    ftp.login('username', 'password')
  File "C:\Python25\lib\", line 373, in login
    if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd)
  File "C:\Python25\lib\", line 241, in sendcmd
    return self.getresp()
  File "C:\Python25\lib\", line 216, in getresp
    raise error_perm, resp
error_perm: 530 User username cannot log in.
The script I have so far is :
from ftplib import FTP
def handleDownload(block):
    print ".",
ftp = FTP('servername')
# Log in to the server
print 'Logging in.'
# Specify username and password 
ftp.login('username', 'password') 
print ftp.login()
directory = '/test/ftp/'
# Change to that directory.  
print 'Changing to ' + directory
# Print the contents of the directory
but i cannot even connect to the FTP not to mention upload/download anything...So any ideas or suggestions would be greatly appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list