当我在shell中手动运行下面的命令时
[root@Rhel67GA-Valencia ~]# /DPDK2/testpmd -c 3 -n 3 -d /DPDK2/librte_pmd_oce.so -w 0000:01:00.00 -w 0000:01:00.01 -- -i --nb-cores=1 --nb-ports=2
我在终端上得到以下输出:
^{pr2}$当我尝试使用pexpect模块在python脚本中运行相同的命令时,我在终端上看不到任何输出,但是这个命令被成功地执行了。在
我需要将上面的命令输出捕获到日志文件中。在
下面是我正在使用的脚本
sample.py:
cmd = "/DPDK2/testpmd -c 3 -n 3 -d /DPDK2/librte_pmd_oce.so -w 0000:01:00.00 -w 0000:01:00.01 -- -i --nb-cores=1 --nb-ports=2"
child = pexpect.spawn(cmd)
child.expect("testpmd>")
child.sendline('start')
print "\ntestpmd> start \n"
time.sleep(30)
child.sendline('stop')
print "\ntestpmd> stop \n"
child.sendline('quit')
time.sleep(30)
在每次调用
child.sendline
之前调用child.expect
:相关问题 更多 >
编程相关推荐