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:
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”)"