我有一个文件需要传递一些参数来开始执行一个进程。该文件是../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"])
我一直在寻找解决方案但是我找不到它,我认为我没有正确地传递参数,我该怎么办呢?
谢谢!
我认为我没有正确地传递这些论点,我该怎么做呢?
只需传递在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"])