Connect to FTP

Chris Rebert clp2 at rebertia.com
Fri Feb 25 13:03:57 EST 2011


On Fri, Feb 25, 2011 at 6:37 AM, foo bar <sofstouki at yahoo.com> wrote:
>
> 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.

Looks like your username-password pair is invalid. Have you checked
whether your credentials work using another FTP client? Have you
checked whether you need to securely login using TLS?

Cheers,
Chris



More information about the Python-list mailing list