发布时间:2019-09-18 07:26:13编辑:auto阅读(2224)
- #!/usr/bin/python
- import pexpect
- import getpass
- remote_path=raw_input('remote_path: ')
- local_file=raw_input('local_file: ')
- passwd=getpass.getpass('password: ')
- for i in range(2):
- file=[line.rstrip() for line in open('/root/ip.txt')]
- cmd='scp -r %s %s:%s'%(local_file,file[i],remote_path)
- child=pexpect.spawn(cmd)
- child.expect('password:')
- child.sendline(passwd)
- child.read()
根据上篇scp稍微做了下修改。
执行此脚本远端服务器密码要相同。
ip.txt格式为:
192.168.21.131
192.168.21.132
……
上一篇: python常用模块收录
下一篇: python 命令行 解析模块 optp
51160
50569
41187
38017
32483
29388
28249
23102
23066
21388
1439°
2151°
1783°
1707°
2010°
1781°
2456°
4134°
4005°
2857°