我有一个文件需要传递一些参数才能开始执行进程。该文件是../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/