You have a space (' '
) character in your username field.
python ftplib weird behaviour
Question
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
Solution
OTHER TIPS
You should pass login & password to __init__ instead of login method:
import ftplib
ftp = ftplib.FTP('my-ftp-server', 'login', 'password')
print(ftp.dir())
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow