发表于 2018-8-11 09:54:21

python scp传文件

  


[*]#!/usr/bin/python
[*]import pexpect
[*]import getpass
[*]host=raw_input('hostname: ')
[*]remote_path=raw_input('remote_path: ')
[*]local_file=raw_input('local_file: ')
[*]passwd=getpass.getpass('password: ')
[*]cmd='scp -r %s %s:%s'%(local_file,host,remote_path)
[*]child=pexpect.spawn(cmd)
[*]child.expect('password:')
[*]child.sendline(passwd)
[*]child.read()
[*]~
  

  

  本人是菜鸟,脚本还有好多地方需要改进。
页: [1]
查看完整版本: python scp传文件