[BusyBox] Scriptable telnet?

Ole-Egil Hvitmyren oehvitmyren at network-electronics.com
Mon Jan 12 13:40:48 UTC 2004


Paul Fox wrote:
>  > > If I want to connect to a telnet server, I do have to negotiate with it.
>  > > I didn't really succeed in it... I tried
>  > > "echo -en 'ls\r\0' | nc <host> <port>" and many similar commands, with
>  > > busybox and inetutils telnet servers. With bb telnetd, sometimes the
>  > > output of the command came back, sometimes didn't, it was very rhapsodic,
>  > > I don't know what it depended on.
>  > 
>  > It's a race condition depending on whether or not EOF from stdin and the 
>  > resulting close of the network conection was registered before the result 
>  > came back from the far end.  When it works, the sequence is:
> 
> i seem to recall solving a similar problem with something that looked
> a lot like:
>   (echo -en 'ls\r\0'; sleep 2) | nc <host> <port>
> or somesuch.  cheap, dirty, and not guaranteed to work.  but it can
> get you where you need to be when all you have are stock binaries.
> e.g., on my current development machine this works:
>   echo 'GET /index.html'| nc www 80
> but this doesn't:
>   echo 'GET /index.html' | telnet www 80
> and this fixes it:
>   (echo 'GET /index.html'; sleep 2) | nc www 80
>

I hope you realize that you just fixed telnet by delaying nc? ;-)

Ole-Egil Hvitmyren




More information about the busybox mailing list