不能用子过程Popen方法调用C++二进制

2024-05-15 21:04:32 发布

您现在位置:Python中文网/ 问答频道 /正文

> subprocess.Popen("ADK -j 50 - ordNode jira1disa2 -a '-noControl -sourceDir /some/path/given/' > logFile.log 2>&1 &")

我写了与上面提到的几乎相同的查询。 ^ }是一个C++二进制,还有一些参数作为选项,我试图通过服务器中的Python脚本运行它。

当我说这句话的时候:

> ADK -j 50 - ordNode jira1disa2 -a '-noControl -sourceDir /some/path/given/' > logFile.log 2>&1 &

在一个.sh文件中,并使用Python运行该文件,我能够执行结果,但在直接调用时,我会遇到如下错误:

Traceback (most recent call last):
  File "test.py", line 47, in <module>
  check_timezone()
  File "test.py", line 40, in check_timezone
  count = subprocess.check_output(command)
  File "/usr/lib/python3.6/subprocess.py", line 537, in check_output
  process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib/python3.6/subprocess.py", line 679, in __init__errread, errwrite)
  File "/usr/lib/python3.6/subprocess.py", line 1249, in _execute_child
  raise child_exception-
  OSError: [Errno 2] No such file or directory

限制:

我不能使用shell=True

我也尝试过在一个包含所有in字符串的列表中给出它,但也失败了,在subprocess.Popen以及许多可能的方式中。。。 请建议一种可行的方法


Tags: inpylibusrchecklinesomefile