Discussion:
Problem with Expect/netcat/telnet
(too old to reply)
Roger Alexander
2010-05-05 19:51:21 UTC
Permalink
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!
Roger Alexander
2010-05-05 19:53:56 UTC
Permalink
Post by Roger Alexander
Hi,
I'm having a problem using Expect to script a Telnet session that is
   spawn netcat -T 10.203.38.68 23
   expect "="
   send "ACC\r"
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
   (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
   (echo 'ACC'; echo OTTER) |flip -m - | netcat -T 10.203.38.68 23
and this worked, the Telnet server responded as expected!
Opps, acidentially hit the Post button by mistake beforeI could finish
my post. So, given my experiements at the command line, on the
surface, it occurred to me that a similar problem is happending in
with Expect. However, everything works fine if I have the Expect
script connect directly to the telnet server instead of going throug
netcat. So, it would seem to be something peculiar to the interacton
between Expect and netcat.

Does anyone out there have any experience doing this sort of thing?

Any suggestions/help is greatly appreciated!!

Thanks,

Roger Alexander.

Continue reading on narkive:
Search results for 'Problem with Expect/netcat/telnet' (Questions and Answers)
4
replies
Tell Me something about denial of services.....?
started 2007-02-20 05:17:40 UTC
security
Loading...