我想打开一个进程并在同一进程中运行两个命令.我有 :
cmd1 = 'source /usr/local/../..'
cmd2 = 'ls -l'
final = Popen(cmd2, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
stdout, nothing = final.communicate()
log = open('log', 'w')
log.write(stdout)
log.close()
Run Code Online (Sandbox Code Playgroud)
如果我使用popen两次,这两个命令将在不同的进程中执行.但我希望它们在同一个shell中运行.
python-2.7 ×1