I am trying to use python to connect a FTP sever and download a file. But I meet troubles when trying to connect to the file server. I can use filezilla to connect to the server. There are 3 connection information I use in filezilla(as picture):
- proxy host/ proxy_user/ proxy_password
- host/ username/ password
- generic proxy: proxy host/ proxy user/ proxy password
But I didn't find related code how to use generic proxy in the python code. So far I have tried these two scripts. How can I resolve this error? Please help me for the same.
Thanks in Advance Guys!
1.
def ftp_login(proxy_host, proxy_user, proxy_password, host, user, password, account):
ftp = FTP()
ftp.connect(proxy_host)
# error on this code
ftp.login(user=proxy_user, passwd=proxy_password)
ftp.sendcmd(f"USER {user}@{host} {proxy_user}")
ftp.sendcmd(f"PASS {password}")
ftp.sendcmd(f"ACCT {account}")
return ftp
import ftplib
# Replace the placeholders with your actual values
proxy_host = "proxy_host"
proxy_user = "proxy_user"
proxy_password = "proxy_password"
host = "host"
user = "user"
password = "password"
account = proxy_password
ftp_connection = ftp_login(proxy_host, proxy_user, proxy_password, host, user, password, account)
return error message
530-
530-Usage: USER username@hostname proxyusername
530- PASS password
530 ACCT proxypassword
- reference by Connecting with ftplib via FTP proxy in Python?
# import ftplib
import ftplib
proxy_host = "proxy_host"
proxy_user = "proxy_user"
proxy_password = "proxy_password"
host = "host"
user = "user"
password = "password"
u = f"{user}@{proxy_host} {proxy_user}"
print(u)
ftp = ftplib.FTP(host, u, password, proxy_password)
return error message
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Finally the type of ftp proxy I use:
USER %u@%h %s
PASS %p
ACCT %w
filezilla proxy setting picture:

