Forum Archive

Help with FTP

TQA

I want to read lines from a text document. But I can't seem to get the FTP connection working..

from ftplib import FTP
ftp=FTP('ftp.mydomain.com')
ftp.login('username','password')
ftp.retrlines('LIST')

I know this will list the directories.

dvader9

I haven't tested this myself, but seeing that you're using the same lines given as an example on the ftplib documentation site, I noticed that you forgot the parentheses for the prot_p() call. You need this to explicitly secure the connection. I'd give that a shot...

TQA

@dvader9: I have those in my program. was a typo when I wrote this post.

dvader9

Are you sure your server accepts TLS connections, as opposed to FTP over SSH (SFTP)?
What error message do you get?

TQA

I do not get any error messages.. just appears to by idle. Doesnt move on through the program. Sorry for short responses, as I am on my phone.

TQA

Am I using anything wrong? I pretty much copied the example program..

EDIT: Trying it again I get "error_perm: 500 AUTH not understood"

EDIT: Sorry for the edits! It seems to be working now..? I switched to just FTP. Is it possible to read/write to a specific file via FTP?

ccc

If you do a Google search on python ftplib example, near the top of the results, you will see two hits from effbot and from pythonforbeginners that read and write files.