0

I need to download a zip file from my implict ftps server. Here is the code which I tried to download the file:

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("hostip")
ftp.put_Username("username")
ftp.put_Password("password")
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!")

#clearing the control channel
success = ftp.ClearControlChannel()
if (success != True):
    print(ftp.lastErrorText())
    sys.exit()
else:
    print(ftp.lastErrorText())
ftpResponse = ftp.feat()
fileSize = ftp.GetSizeByName("15_20.zip")
if (fileSize < 0):
    print("file does not exist")
else:
    print("file exists and is " + str(fileSize) + " bytes in size")

ftp.put_RestartNext(True)
localFilename = "C://mcx5min//14_40.zip" # copy the path from the old mcx.py
remoteFilename = "14_40.zip"
success = ftp.GetFile(remoteFilename, localFilename)
if (success != True):
    print(ftp.lastErrorText())
    sys.exit()
ftp.Disconnect()

In this program I'm able to login to my ftps server and also able to find the existence of file in it. But when I try to download the file through GetFile() function its throwing an error like "426 data connection closed, SSL/TLS negotiation failed". I don't know exactly what was the error am locally using windows server.I am really very new to this. So please anybody help me out to solve this issue.

linusg
  • 6,289
  • 4
  • 28
  • 78
shilpa
  • 159
  • 1
  • 1
  • 12
  • Use pythons standard lib `FTP` class. – linusg Apr 26 '16 at 10:54
  • You could use [this](http://stackoverflow.com/a/12424311/2935386) for reference, if you choose `ftplib`. – harry Apr 26 '16 at 10:59
  • thanks for your solutions but i tried ftblib too. it doesn't work for me.the code which i attached above in my question is able to fetch the file from the remote directory but when i try to downloading the same file am getting replylineQP:426 data connection closed,SSL/TLS negotiation failed error. really don't know where am doing wrong. so please help me out to solve this issue. – shilpa Apr 27 '16 at 11:44

0 Answers0