commands = f"""ssh root@120.7x.254.99 -p2483 cd /data/wwwroot/csjs2_client_dev git pull ssh://git@172.16.x.161x:2483/data/repos/csjs2_client_dev.git """ import subprocess def subprocess_popen(commands,stdout=subprocess.PIPE, stderr=subprocess.STDOUT): current_process = subprocess.Popen(commands, stdout=stdout, stderr=stderr) standoutput, standerr = current_process.communicate() current_process.wait() current_process.kill() print(standoutput) return standoutput subprocess_popen(commands)
备注:commands写的时候第一行 一定要有 否则按照空行 会报错
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/python/281961.html