โ09-23-2021 04:42 AM
Hello,
Can you please help me to how to connect ftp server using python script in snaplogic
Thanks
Mahesh
โ09-23-2021 05:04 AM
Hi @Mahesh7225,
Is there a particular reason not to use the Read & Write snaps for manipulating files on FTP? If you decide to go through Python after all, youโll need to use the ftplib library. You can find detailed information on how to use it on the following link:
ftplib โ FTP protocol client
Regards,
Bojan
โ09-23-2021 10:52 PM
Hi bojanvelevski,
Thanks for reply , through read/write/directory browser snap, i am unable to connect to the ftp server (error :- โUnable to create filesystem object for sftpโ , message:- โFailed to get SFTP session connectedโ) so trying to connect through script.
Thanks
Mahesh
โ09-23-2021 11:22 PM
Usually it is a syntax error in the SFTP path. It needs to follow the next convention:
sftp://server-name/main-directory/sub-directory/file.txt
If that is ok, re-check your account information.
โ09-24-2021 05:31 AM
i tried this but still getting error โReason: _socket.error: [Errno 111] Connection refused in โ
#from com.snaplogic.scripting.language import pysftp
#from import ScriptHook
from ftplib import FTP
from com.snaplogic.scripting.language import ScriptHook
from com.snaplogic.scripting.language.ScriptHook import *
myHostname = โhostnameโ
myUsername = โusernameโ
myPassword = โpasswordโ
ftp = FTP(โhostnameโ,โ22โ)
ftp.login(โusernameโ,โpasswordโ)"