[英]expect script error interact: spawn id exp4 not open
我有一個腳本,它可以正常工作,但最后,當它終止時,會產生這個錯誤:
interact: spawn id exp4 not open
while executing
"interact"
(file "./pippo.sh" line 8)
代碼是:
#!/usr/bin/expect
# Spawn Python and await prompt
spawn mono OpenSim.exe
expect_background {
"Now recording all stats to file every {0}ms" { sleep 10 ; send "stats record stop\n" ; expect "Stopped recording stats to file." {sleep 5 ; send "quit\n"} }
}
interact
如果當您的expect_background
發送quit\n
時,生成的進程退出,這是正常的。 這將關閉連接到進程的文件描述符( spawn id ),因此當它嘗試繼續讀取(或寫入)進程時, interact
將失敗。
您可以通過在后台命令中添加一行來檢測文件結尾並在檢測到文件結束時退出來抑制錯誤:
expect_background {
"Now recording all stats to file every {0}ms" \
{ sleep 10 ; send "stats record stop\n" ; \
expect "Stopped recording stats to file." \
{ sleep 5 ; send "quit\n"; \
expect eof exit } } }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.