지금 당장 혼란스러워합니다. 다음pexpect 및 셸 메타 문자 (>, | 또는 *)
pexpectdocumentation 상태 : 내가 |
및 pexpect.sendline(some command | grep 'something')
에서 *
를 사용하는 오래된 코드를 찾고 있어요 그러나
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 모듈을 사용하지 않는다는 것을 언급 할 가치가있다. 파이썬을위한 오래된 오래된 pexpect이다.
어째서? 왜 pexpect에 메타 문자가 작동하지 않는다고 말하면 분명히일까요?
코드는'pexpect.sendline()'에 무엇을 전달합니까? – ecatmur
@ecatmur, 특정 기계 명령. 일반적으로 | grep 명령 또는 | 및 *. 위의 수정 된 코드를 참조하십시오. – theAlse