def exec_command (shell_cmd、主机名=None):
如果主机名
:
p=Popen (“/usr/bin/ssh tq”+主机名、shell=True, stdout=管,stdin=管)
p.stdin.write (str.encode (shell_cmd))
p.stdin.flush ()
:
p=Popen (shell_cmd shell=True, stdout=管,stdin=管)
stdout, stderr=p.communicate ()
返回stdout, stderr, p.poll ()