1

我必须在 Ubuntu 中调用一个可执行文件......刚刚学会了如何通过subprocess.Popen在 Windows 中使用来完成这项工作。现在,我需要在 Ubuntu 中重复这一步。

我使用了以下 Python 命令:

a=subprocess.Popen("filename.exe",shell=0)

回报是

Traceback (most recent call last):
  File "/untitled0.py", line 29, in <module>
    a=subprocess.Popen("filename.exe",shell=0)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

如果我更改shell=1,则不会有任何投诉,但也不会生成任何输出文件。

file filename.exe 我已经使用它返回 检查了这个文件的类型:

filename.exe:ELF 64 位 LSB 可执行文件,x86-64,版本 1 (SYSV),动态链接(使用共享库),用于 GNU/Linux 2.6.9,未剥离

那么是否可以subprocess.Popen在 Ubuntu 中使用它来调用它?

4

1 回答 1

3

快速阅读 python 文档,看起来你做对了,所以 . 如何尝试执行说 /bin/false 这应该是您系统上已知的工作 exe。如果可行,那么您的 exe 可能是错误的(在 32 位系统上可能是 64 位)

于 2012-05-03T02:17:55.653 回答