小编ags*_*ags的帖子

通过调用unix-shell命令在python中进行Sftp

我们如何通过使用os.system在python脚本中调用unix shell命令将文件从源主机ftp发送到python中的目标服务器...请帮助

I have tried the following code

dstfilename="hi.txt"
host="abc.com"
user="sa"

os.system("echo cd /tmp >sample.txt)
os.system("echo put %(dstfilename)s" %locals())  // line 2 
os.system("echo bye >>sample.txt")
os.system("sftp -B /var/tmp/sample.txt %(user)s@%(host)s)


How to append this result of line to sample.txt?
os.system("echo put %(dstfilename)s %locals()) >>sample.txt" // Seems this is syntatically not correct.

cat>sample.txt      //should look like this
cd /tmp
put /var/tmp/hi.txt
bye

Any help?

Thanks you
Run Code Online (Sandbox Code Playgroud)

python unix sftp command

3
推荐指数
1
解决办法
4398
查看次数

标签 统计

command ×1

python ×1

sftp ×1

unix ×1