问题描述
我正在尝试编写一个期望脚本,我期望处理的提示是 ade 123456789: / >
。数字 123456789 会改变,所以我虽然我可以匹配唯一的 > 我期待收到。然而,我似乎无法让它工作。
#!/usr/bin/expect
set timeout 3
set uuid [lindex $argv 0]
spawn telnet localhost 1402
expect ">"
send "/proc/OBRP/ObjectByUUID $uuid"
在调试中使用 expect.sh my_uuid
调用脚本给了我以下输出。它似乎发送命令,但我没有看到输出,而如果手动运行,我会看到。
expect version 5.45.4
argv[0] = /usr/bin/expect argv[1] = -d argv[2] = ./expect.sh argv[3] = 1234ABCD-ABCD-123A-123A-123456ABCDEF
set argc 1
set argv0 "./expect.sh"
set argv "1234ABCD-ABCD-123A-123A-123456ABCDEF"
executing commands from command file ./expect.sh
spawn telnet localhost 1402
parent: waiting for sync byte
parent: telling child to go ahead
parent: Now unsynchronized from child
spawn: returns {1905}
expect: does "" (spawn_id exp4) match glob pattern "ade 123456789: / >"? no
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
ADE 4.1 - Console Ready.
ade 123456789: / >
expect: does "Trying ::1...\r\nTrying 127.0.0.1...\r\nConnected to localhost.\r\nescape character is '^]'.\r\nADE 4.1 - Console Ready.\r\n\u001b[K\r\nade 123456789: / > " (spawn_id exp4) match glob pattern "ade 123456789: / >"? yes
expect: set expect_out(0,string) "ade 123456789: / >"
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "Trying ::1...\r\nTrying 127.0.0.1...\r\nConnected to localhost.\r\nescape character is '^]'.\r\nADE 4.1 - Console Ready.\r\n\u001b[K\r\nade 123456789: / >"
send: sending "/proc/OBRP/ObjectByUUID 1234ABCD-ABCD-123A-123A-123456ABCDEF" to { exp4 }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)