Python ftplib - specify port
After searching numerous solutions, a combination of the docs.python.org and the connect
command solved my issue.
from ftplib import FTP_TLShost = 'host'port = 12345usr = 'user'pwd = 'password'ftps = FTP_TLS()ftps.connect(host, port)# Output: '220 Server ready for new user.'ftps.login(usr, pwd)# Output: '230 User usr logged in.'ftps.prot_p()# Output: '200 PROT command successful.'ftp.nlst()# Output: ['mysubdirectory', 'mydoc']
If you're using plain FTP instead of FTPS, just use ftplib.FTP
instead.