python - 如何在Python中执行这个unix进程?连接参数时出现问题

标签 python shell unix process scripting

我有一个文件需要传递一些参数才能开始执行进程。该文件是../main/serv。 如果我在 unix shell 终端中执行此命令,一切都会正常。

../main/serv -o phy=dhc=file:serv:1 -o in=dhc,0 -o out=file:phy_out:1 -o eui48=01:00:00:00:00:00

我从 python 脚本中调用此函数来启动该进程,但不起作用。

    subprocess.call(["../main/serv", "phy=", "dhc=file:serv:1", "in=", "dhc,0", "out=" , "file:phy_out:1", "eui48=01:00:00:00:00:00"])

我一直在寻找解决方案,但没有找到,我认为我没有正确传递参数,我该怎么办?

谢谢!

最佳答案

I think that I'm not passing correctly the arguments, how can I do it?

只需传递与在 shell 中执行命令时传递的参数相同的参数,因此请进行更改

    subprocess.call(["../main/serv", "phy=", "dhc=file:serv:1", "in=", "dhc,0", "out=" , "file:phy_out:1", "eui48=01:00:00:00:00:00"])

    subprocess.call(["../main/serv", "-o", "phy=dhc=file:serv:1", "-o", "in=dhc,0", "-o", "out=file:phy_out:1", "-o", "eui48=01:00:00:00:00:00"])

关于python - 如何在Python中执行这个unix进程?连接参数时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54889630/

相关文章:

regex - 更改匹配行中的单词

linux - Unix 终端错误 - "cp: the -R and -r options may not be specified together."

python - 使用 Twisted, 'connectionMade' 如何触发特定的 Deferred?

mysql - 尝试执行 mysqldump 命令时出现错误 1064(42000)

python -SSL : CERTIFICATE_VERIFY_FAILED

unix - 如何删除列?

javascript - 如何使用 shell 脚本文件运行我的 Node 脚本

Python树结构

python - 通过多个循环合并 Excel 工作表

python - 未实现错误: Cast string to float is not supported