[英]Python Pexpect issue : Getting prompt between the command and result
我可以看出這不是 Python/Pexpect 問題,而是兩台 Linux 機器相互通信的方式。
但如果有人能幫我找到解決這個問題的方法,我將不勝感激。
我發出命令,然后等待提示,獲取 Before 並查找我需要的內容(響應),然后我繼續執行下一個命令。
發生的事情是,我看到在收到命令之前發出命令,然后是命令提示符。
cmd = 'rm /usr/local/file'
self.myobj.sendline(cmd)
match = self.myobj.expect(self.prompts, timeout=timeout)
print self.dut_host.before
print self.dut_host.after
如果我手動做,我會得到類似的東西
MYPROMPT> rm /usr/local/file
rm: cannot remove '/usr/local/file': No such file or directory
但是打印出來的是
MYPROMPT> rm /usr/local/file <-- self.dut_host.before
MYPROMPT> <--- self.dut_host.after
我將在下一個命令中看到實際的 output 並最終終止我的程序。
有沒有人遇到過這個問題,誰能建議我解決這個問題的方法。
提前致謝!!
像這樣更改代碼:
cmd = 'rm /usr/local/file'
self.myobj.sendline(cmd)
print self.dut_host.before
print self.dut_host.after
match = self.myobj.expect(self.prompts, timeout=timeout)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.