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