I wish to send a simple command via telnet such as:
echo "my_command arg1 arg2" | telnet host port
but I'm finding that my program running on $host:$port
doesn't actually receive the command. (It only accept()s &
close()s the connection.)
I can solve my problem with a delay:
(echo "my_command arg1 arg2" && sleep 1) | telnet host port
However I don't really want to do that as sometimes I have
multiple commands to send (& the time it takes to finish varies)
& it is useful to me that control returns to my shell ASAP.
I suspect that the telnet program is receiving a SIGPIPE
before it is able to actually send out the commands.
So, my question is:
How can I get telnet to flush the commands before it closes
the connection & returns control to my shell?
Any info/pointers muchly appreciated.