![]() |
file transfer via python SFTP SCP - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: file transfer via python SFTP SCP (/thread-38158.html) |
file transfer via python SFTP SCP - mg24 - Sep-10-2022 Hi Team, I am transfering csv files to cloud via SFTM transfer. below code is works when i use subprocess.Popen but doesnt work if i use run command. subprocess.run(['scp',fname,landing_path] ) i am using windows. def File_transfer(fpath,tbl) import subprocess import os fname = os.path.join(fpath,tbl) landing_path = '"I:\\Test_cloud.txt",[email protected]://disk4//app/landing' subprocess.Popen(['scp',fname,landing_path]) if __name__ == "__main__": fpath = "D:\\Reports" tbl = "Table1.zip" RE: file transfer via python SFTP SCP - Gribouillis - Sep-10-2022 (Sep-10-2022, 04:36 AM)mg24 Wrote: but doesnt work if i use run command. subprocess.run(...In the code shown above, you are not using subprocess.run() but subprocess.Popen() , also the File_transfer() function is never called. Also « it doesn't work » is not a usable error report. Describe what happens when you run the code, and all output.
RE: file transfer via python SFTP SCP - snippsat - Sep-10-2022 Also should get syntax error on line 1 as missing : .Import statement should be on top of code. Here a working test for upload with scp from Windows to our Linux server.import subprocess import os def file_transfer(fpath, tbl): fname = os.path.join(fpath, tbl) landing_path = "[email protected]:/var/www/python-forum.io/images/tips" subprocess.run(['scp', '-P', '2xxx', fname, landing_path]) if __name__ == "__main__": # On server from Win to Linux Path is like this # G:\1_bilder\logo\speed.png fpath = "/G/1_bilder/logo/" tbl = "speed.png" file_transfer(fpath, tbl) RE: file transfer via python SFTP SCP - mg24 - Sep-15-2022 Hi Team, Here a working test for upload with scp from Windows to our Linux server. What changes to make to transfer files if its windows to windows server. in below code subprocess.run(['scp', '-P', '2xxx', fname, landing_path]) |