- 论坛徽章:
- 0
|
编写路由器自动巡检脚本:
路由器的提示符为 [test]
本意想实现 匹配 [test]成功,在执行命令,但调试中(见附件)发现:
"Trying 192.168.1.20...\r\r\nConnected to 192.168.1.20.\r\r\nEscape character is '^]'.\r\r\n"
与[test]匹配上了,个人猜测是否 [test] 为保留字符。
另,[test] 我也是按参数的方式传递给 expect 脚本的,从调试中看,传递又是正确的,如何解决这种情况呢?
expect: does "Trying 192.168.1.20...\r\r\nConnected to 192.168.1.20.\r\r\nEscape character is '^]'.\r\r\n" (spawn_id exp4) match glob pattern "sleep"? no
"Username or password is invalid."? no
"password:"? no
"<test>"? no
"[test]"? yes
expect: set expect_out(0,string) "e"
expect: set expect_out(spawn_id) "exp4"
"Trying 192.168.1.20...\r\r\nConnected to 192.168.1.20.\r\r\nEscape character is '^]'.\r\r\n"
|
|