我现在很困惑。
pexpect 文档说明如下:
Remember that Pexpect does NOT interpret shell meta characters such as
redirect, pipe, or wild cards (>, |, or *). This is a common mistake.
If you want to run a command and pipe it through another command then
you must also start a shell. For example::
child = pexpect.spawn('/bin/bash -c "ls -l | grep LOG > log_list.txt"')
child.expect(pexpect.EOF)
但是,我正在查看一些使用|
和*
in 的旧代码pexpect.sendline(some command | grep 'something')
。所以我开始测试这些命令,它们似乎都可以工作。还值得一提的是,我没有使用修改过的 pexpect 模块,它是 python 的普通旧 pexpect。
怎么来的?为什么pexpect提到元字符不起作用,而它显然这样做?