在 linux bash 中运行以下命令成功:
gimp --no-interface -b '(python-fu-scale RUN-NONINTERACTIVE 0 0 "img.jpg")' -b '(gimp-quit 0)'
输出:
batch command executed successfully
被打印并且子进程退出
用 python3.5 运行它失败:
import subprocess
subprocess.run("gimp --no-interface -b '(python-fu-scale RUN-NONINTERACTIVE 0 0 \"img.jpg\")' -b '(gimp-quit 0)'".split())
结果输出:
batch command executed successfully
batch command executed successfully
并且子进程卡住了。
我不确定有什么区别以及如何在 python 中实现等效行为。有没有办法将 bash 命令作为字符串运行?