十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
def exec_command(shell_cmd, hostname=None):
if hostname:
p = Popen('/usr/bin/ssh -Tq '+hostname, shell=True, stdout=PIPE, stdin=PIPE)
p.stdin.write(str.encode(shell_cmd))
p.stdin.flush()
else:
p = Popen(shell_cmd, shell=True, stdout=PIPE, stdin=PIPE)
stdout, stderr = p.communicate()
return stdout, stderr, p.poll()