Connect to FTP

foo bar sofstouki at yahoo.com
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\FTPDownload.py", line 19, in <module>
    ftp.login('username', 'password')
  File "C:\Python25\lib\ftplib.py", line 373, in login
    if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd)
  File "C:\Python25\lib\ftplib.py", line 241, in sendcmd
    return self.getresp()
  File "C:\Python25\lib\ftplib.py", 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):
    file.write(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
ftp.cwd(directory)
# Print the contents of the directory
ftp.retrlines('LIST')
 
 
but i cannot even connect to the FTP not to mention upload/download anything...So any ideas or suggestions would be greatly appreciated.
 
Thanks!
 


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110225/77ea159d/attachment.html>


More information about the Python-list mailing list