mitogen附带文件到远程主机
#!/usr/bin/env python # import mitogen.master import mitogen.select import subprocess import logging import mitogen.utils import time import os def read_local(): with open('/Users/Redheat/Downloads/cmake-3.12.1-Darwin-x86_64.dmg','rb') as f: return f.read() def main(router): local = router.local(debug=True) file_content = local.call(read_local) hostnames = ['192.168.101.25', '192.168.101.27', '192.168.101.29'] remote_hosts = [router.ssh(hostname=hostname, username='root', check_host_keys='accept') for hostname in hostnames] rc = [remote_host.call(write_local,file_content) for remote_host in remote_hosts] print('Command return code was:', rc) def write_local(file_content): with open('/tmp/cmake-3.12.1-Darwin-x86_64.dmg', 'wb') as f: f.write(file_content) if __name__ == '__main__': logging.basicConfig(level=logging.INFO) mitogen.utils.run_with_router(main)
本博客内容都是博主试验通过的方案与方法.
如需交流,请发邮件至qjyyn#qq.com