SUMMARY: Telnet output lost when piped

From: Patricio Mora <>
Date: Fri Mar 09 2007 - 04:57:52 EST
Thanks to Darren , Casper and Crist Clark, Mouline Kamal, whose 
responses were all useful.

Darren's hint:
          use netcat instead of telnet
works fine and will be used preferrably

Casper's solution:
         (sleep 20 | telnet server port)
works great from Solaris 10 crontab and will be used where netcat can't 
be installed

Mouline's solution:
          use netcat instead of telnet
won't be tested, I had previous experience with netcat, and I prefer it

Darren's whole response:

'telnet' isn't particularly good for non-interactive use.  It really
wants to allocate ptys and things.
Especially since your remote server isn't actually telnet (and doesn't
need all the extra bits of the telnet protocol), I'd suggest using
'netcat' instead.  It's much more easily scripted.  If you're looking
for packages, it is often also called 'nc'.

Casper's whole response:

This is a tricky queston; the telnet client will abort the session
as soon as it has no more data to send.
What you need to do is something like:
	echo Probing $host
	(sleep 20 | telnet $host)

Great work !! Thanks. escribis:
> Hello.
> I have a script configured to be called through inetd, which echos a phrase
> when telnet'ed. Everytime I put the line "telnet server port" to the right of
> a pipe, and also when I call it from crontab., the echo doesn't appear. In a
> terminal the command goes as expected. Through cron I see the usual
> "Probing 10.244....
>  Connected to ...
>  Escape character is ...
>  Connection closed by foreign host"
> But no hint of my echo. I've played with TERMs types and redirections to no
> result. Any ideas how to get the whole output?
> Thanks in advance.
> _______________________________________________
> sunmanagers mailing list
sunmanagers mailing list
Received on Fri Mar 9 04:58:33 2007

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:05 EST