Reputation: 114
What happens when I pipe any command to a telnet session , why does the session closes . How can I give a command which can be processes instead of closeing the connection .
I am trying
echo "xvz" | telnet 0 abc Trying 0.0.0.0... Connected to 0. Escape character is '^]'.
Which terminates the session instead of process xyz , what is other way i also tried
telnet 0 xyz < test
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
Connection to 0 closed by foreign host.
Upvotes: 4
Views: 6412
Reputation: 738
I have found that using nc (netcat) instead of telnet works nicely for simple commands:
echo "command to send"|nc host 1234
Upvotes: 1
Reputation: 41
echo
the command(s) you want to send, then use cat
to keep the connection open.
{ echo "commands to send"; cat -; } | telnet localhost 8080
While the connection is open, you can type commands as usual, but you cannot send the escape character to telnet.
To close the connection, press Ctrl+C.
Upvotes: 1
Reputation: 115
Try eval
:
eval "{ echo;
sleep 5;
echo 'xvz';
sleep 10; }" | telnet your_host
Use sleep
s to keep open the connection; try different delay times.
Upvotes: 0
Reputation: 1243
telnet does not process standard input and standard output.
You should check other programs like 'expect'.
Upvotes: 1