Reputation: 8246
I'm running into some very strange behaviour when trying to connect to a ftp server using ftplib. What I'm doing is:
import ftplib
ftp = ftplib.FTP('my-ftp-server')
ftp.login('user ', 'pass')
Now if I run these from a python interpreter it work fine and I get:
'230 Login successful.'
But I want to have these in a nice script that can do stuff for me. When I put these all in some python script and run:
python my_ftp_stuff.py
I get:
ftplib.error_perm: 530 Login incorrect.
I really am clueless as to what can cause this weird behaviour. Does anyone have any tips on what to try?
Best regards
Upvotes: 4
Views: 2238
Reputation: 19
You should pass login & password to __init__ instead of login method:
import ftplib
ftp = ftplib.FTP('my-ftp-server', 'login', 'password')
print(ftp.dir())
Upvotes: 2