1
Pexpect를 사용하여 원격 방화벽과 상호 작용합니다. 상호 작용의 모든 것은 괜찮습니다.하지만 child.before로 결과를 얻으려고 할 때, 나는 원하는 것을 얻지 못합니다.Pexpect가 올바르게 출력되지 않습니다.
child = pexpect.spawn('ssh [email protected]')
child.sendline(password)
child.expect('>')
child.sendline('set cli pager off')
child.expect('>')
child.send('show system info')
child.expect('>')
child.before
내가 child.before의 문장에서 얻을 출력은 다음과 같습니다 : 이것은 내 코드입니다
그래서'CLI 설정 \ 연구 \ X1B [kadmin을 (활성) 이름 @'
[email protected](active)> set cli pager off
[email protected](active)> show system info
hostname: name
ip-address: ip
# ...There are more lines but these are omitted here...
[email protected](active)>
톤 : 방화벽 측면에서
이 내가 (그것은) (child.interact에서 직접 복사) 수신있어 상호 작용입니다 그는 방화벽과의 상호 작용이 정확합니다. 내가 출력을 얻을 수없는 이유는 무엇입니까? 내가 도대체 뭘 잘못하고있는 겁니까? 당신의 도움에 대한
덕분에, 당신은 child.sendline('show system info')
에 child.send('show system info')
을 변경해야합니다
마이크
'ssh '를 직접 사용하여 연결 했으므로, 기대하지 않고 [Paramiko] (http://www.paramiko.org/)를 사용 해본 적이 있습니까? 더 빠를 것이며 터미널 문제에 대해 걱정할 필요가 없습니다. –