3
我想打开一个进程并在同一进程中运行两个命令。我有:Python:如何在一个进程中使用popen运行多个命令
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()
如果我使用popen两次,这两个命令将在不同的进程中执行。但我希望它们在同一个shell中运行。