2024-10-02 10:26:36 发布
网友
我有一个脚本,我喜欢通过子进程在python中执行(是的,它必须在sh中)。 现在我这样称呼sh:
sh
subprocess.check_call( ['sh' + command] )
其中command是:
command
不幸的是,这让我:
sh: 0: Can't open echo 'someformat : : '${ENV_VAR}'/efc ;' > targetfile
有人能告诉我让命令在sh中工作的步骤,并解释原因。在
必须使用-c参数运行sh:
-c
subprocess.check_call( ['sh', '-c', command] )
试试这个:
command = "echo 'someformat : : '${ENV_VAR}'/efc ;' > targetfile" subprocess.check_call(["sh", "-c", command])
参数-c修改{}行为,以从下一个参数的字符串中读取命令。 参数必须包含在列表中。在
必须使用
-c
参数运行sh:试试这个:
参数}行为,以从下一个参数的字符串中读取命令。
参数必须包含在列表中。在
-c
修改{相关问题 更多 >
编程相关推荐