Roger Alexander
2010-05-05 19:51:21 UTC
Hi,
I'm having a problem using Expect to script a Telnet session that is
front-ended with netcat. I use the following to get things started:
spawn netcat -T 10.203.38.68 23
expect "="
send "ACC\r"
expect "Password: ? @@@@@@@@"
The connection occurs just fine. However, nothing happens after the
send commad. It occurred to me that perhaps netcat is not passing the
\r through. I've tried \r, \r\n, \n\r, and \n, but no joy. I went to
the command line and entered the following:
(echo 'ACC'; echo JEEPERS) | netcat -T 10.203.38.68 23
and this yielded the same behaivor -- i.e., that nothing was received
back from the Telnet device. For a lark, I used flip to translate the
newline into CR/LF pairs:
(echo 'ACC'; echo OTTER) |flip -m - | netcat -T 10.203.38.68 23
and this worked, the Telnet server responded as expected!
I'm having a problem using Expect to script a Telnet session that is
front-ended with netcat. I use the following to get things started:
spawn netcat -T 10.203.38.68 23
expect "="
send "ACC\r"
expect "Password: ? @@@@@@@@"
The connection occurs just fine. However, nothing happens after the
send commad. It occurred to me that perhaps netcat is not passing the
\r through. I've tried \r, \r\n, \n\r, and \n, but no joy. I went to
the command line and entered the following:
(echo 'ACC'; echo JEEPERS) | netcat -T 10.203.38.68 23
and this yielded the same behaivor -- i.e., that nothing was received
back from the Telnet device. For a lark, I used flip to translate the
newline into CR/LF pairs:
(echo 'ACC'; echo OTTER) |flip -m - | netcat -T 10.203.38.68 23
and this worked, the Telnet server responded as expected!