我正在尝试使用命令替换从 python 脚本构建 linux 命令,但无法使以下简单示例正常工作:
LS="/bin/ls -l"
FILENAME="inventory.txt"
cmd = "_LS _FILENAME "
ps= subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
output = ps.communicate()[0]
print output
谢谢!
JB