commands = f"""ssh [email protected] -p2483 cd /data/wwwroot/csjs2_client_dev git pull ssh://[email protected]: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写的时候第一行 一定要有 否则按照空行 会报错标签:commands,standoutput,stdout,python,cmd,subprocess,current,process,管道 From: https://www.cnblogs.com/wusen0601/p/16619356.html