Python 官方文档:入门教程 => 点击学习
#!/usr/bin/python import pexpect import getpass remote_path=raw_input('remote_path: ') local_file=raw_input('local_fil
- #!/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
……
--结束END--
本文标题: python scp 批量传文件
本文链接: https://www.lsjlt.com/news/190742.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0