我現在很困惑。pexpect和shell元字符(>,| |或*)
Pexpect的documentation狀態如下:
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)
不過我期待在使用|
和pexpect.sendline(some command | grep 'something')
*
一些舊的代碼。 所以我開始測試這些命令,它們都似乎工作。另外值得一提的是,我沒有使用修改後的pexpect模塊,它對python來說是一個普通的老方法。
怎麼回事?爲什麼pexpect提及元字符不工作,當它明顯這樣做?
代碼傳遞給'pexpect.sendline()'是什麼? – ecatmur
@ecatmur,機器特定的命令,但通常使用|在命令或|之後的grep和*。請參閱上面的修訂代碼 – theAlse