Linux里,shell脚本连接sftp

from subprocess import call
def main():
cmd5 = “”“sftp -oIdentityfile=…openssh targetAddress < put filename
exit
EOT”""
call(cmd5,shell=True)
if name == ‘main’:
main()

注意:

  1. EOT: end of text。 EOF: end of file
  2. 最后的一个EOT前后不能有换行,空格,制表符
  3. 要用三个引号""" 否则报错SyntaxError: EOL while scanning string literal
  4. sftp部分命令:
    ls, help, get xxxfile, put xxxfile, quit/bye/exit

你可能感兴趣的:(Linux)