I'm trying to write an expect script, the prompt I am expecting to handle is ade 123456789: / >
. The number 123456789 will change, so I though I could just match on the only > I'm expecting to receive. I can't seem to get it to work however.
#!/usr/bin/expect
set timeout 3
set uuid [lindex $argv 0]
spawn telnet localhost 1402
expect ">"
send "/proc/OBRP/ObjectByUUID $uuid"
Calling the script with expect.sh my_uuid
in debug gives me the following output. It seems to send the command but I don't see the output, whereas I do if run manually.
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 }