2016-04-22 7 views
0
herunterladen

Ich muss ftps Server in Windows anmelden, bin den Code, den ich versuchte, eine Verbindung mit FTPs zu verbinden.wie ein Verzeichnis von FTP-Server mit Python in Windows

from ftplib import FTP_TLS 
ftps = FTP_TLS('my host addres',990) 
ftps.login('username','password')   
ftps.prot_p()   
ftps.retrlines('LIST') 

wenn ich dieser Code ausführen kannte einen Socket-Fehler ist immer kein 10060.i meiner ftp-Verbindung ist implicit.I sehr neu ist mir jemand python.so bitte um dieses Problem zu lösen helfen.

Antwort

0

Hier ist die Antwort für meine Frage.in Python gibt es ein Modul namens chilkat mit dem ich mich in meinen impliziten ftps-Server einloggen kann.

import sys 
import chilkat 

ftp = chilkat.CkFtp2() 

# Any string unlocks the component for the 1st 30-days. 
success = ftp.UnlockComponent("Anything for 30-day trial") 
if (success != True): 
    print(ftp.lastErrorText()) 
    sys.exit() 

# If this example does not work, try using passive mode 
# by setting this to True. 
ftp.put_Passive(False) 
ftp.put_Hostname("ur host ip") 
ftp.put_Username("usename") 
ftp.put_Password("passowrd") 
ftp.put_Port(990) 

# We don't want AUTH SSL: 
ftp.put_AuthTls(False) 

# We want Implicit SSL: 
ftp.put_Ssl(True) 

# Connect and login to the FTP server. 
success = ftp.Connect() 
if (success != True): 
    print(ftp.lastErrorText()) 
    sys.exit() 
else: 
    # LastErrorText contains information even when 
    # successful. This allows you to visually verify 
    # that the secure connection actually occurred. 
    print(ftp.lastErrorText()) 

print("FTPS Channel Established!") 

# Do whatever you're doing to do ... 
# upload files, download files, etc... 
localFilename = "c:/temp/hamlet.xml" 
remoteFilename = "hamlet.xml"#the file name which u download from the ftps 
# Download a file. 
success = ftp.GetFile(remoteFilename,localFilename) 
if (success != True): 
    print(ftp.lastErrorText()) 

ftp.Disconnect() 
Verwandte Themen