如何在Python中执行此unix进程?连接参数时的问题

问题描述 投票:1回答:1

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

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

谢谢!

python shell unix process scripting
1个回答
0
投票

我认为我没有正确地传递这些论点,我该怎么做呢?

只需传递在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"])
© www.soinside.com 2019 - 2024. All rights reserved.