mitogen附带文件到远程主机
Posted redheat
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)
以上是关于mitogen附带文件到远程主机的主要内容,如果未能解决你的问题,请参考以下文章