【发布时间】:2022-01-22 17:13:47
【问题描述】:
我正在尝试在 python 中执行一个 shell 脚本,但我没有得到预期的结果
脚本.sh
#!/bin/bash
file1=$1
file2=$2
cat $file1 $file2
蟒蛇:
print(sp.run(/path/script.sh + " text1.txt text2.txt", shell=True, check=True, text=True, capture_output=True))
如果我在终端上运行脚本结果是正确的,我会加入这两个文件。 但是如果我运行 python 代码,它似乎什么都不做。
【问题讨论】:
-
/path/script.sh不是有效的 Python 文字。
标签: python shell subprocess