From: Roger Alexander on
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!
From: Roger Alexander on
On May 5, 12:51 pm, Roger Alexander <rtalexan...(a)mac.com> wrote:
> 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!

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.