from subprocess import call
def main():
cmd5 = “”“sftp -oIdentityfile=…openssh targetAddress <<EOT
put filename
exit
EOT”""
call(cmd5,shell=True)
if name == ‘main’:
main()
注意:
- EOT: end of text。 EOF: end of file
- 最后的一个EOT前后不能有换行,空格,制表符
- 要用三个引号""" 否则报错SyntaxError: EOL while scanning string literal
- sftp部分命令:
ls, help, get xxxfile, put xxxfile, quit/bye/exit