0
我寫下了腳本。期望命令輸出被存儲在一個變量中
#! /usr/bin/expect
set timeout 180
spawn /vobs/iov/rnc/bin/moshell/moshell -d db.dat
expect {
-re "OFFLINE_DB.DAT.*" { }
timeout {
error "\n######## Timeout - when logging in\n"
}
eof {
error "\n######## eof - when logging in\n"
}
}
set db_prompt "SQL>"
send "select id from motype_r1 where data = 'PlugInUnit';\r"
expect {
-re "OFFLINE_DB.DAT>"
}
exit
現在,我想表的輸出變量即
+------+
| id |
+------+
| 19 |
+------+
Query Done: 1 record selected
並匹配正則表達式中多了一個varible得到 '19'。
任何人都可以請幫助我的解決方案。
/Akshya
歡迎來到StackOverflow。請使用代碼標籤來設置您的代碼示例的格式,並向該問題添加更多信息。還要在您的問題中添加相關標籤。 – 2010-07-21 12:36:20