LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Piping to telnet 80 failing (https://www.linuxquestions.org/questions/linux-networking-3/piping-to-telnet-80-failing-405176/)

michaelsanford 01-18-2006 08:53 PM

Piping to telnet 80 failing
 
We're using a dynamic dns providor's script (referring to the CGI) to update our IP address (by their instructions) like so:

Code:

telnet host.com 80
GET /ip.cgi?host=our.host.com&key=g1c48672b5ba99d49d0a684aaac58b56
OK Host updated

However, when I do this from the shell, nothing works:
Code:

export DOMAIN_COMMAND="GET /ip.cgi?host=our.host.com&key=g1c48672b5ba99d49d0a684aaac58b56"
( sleep 1 ; echo $DOMAIN_COMMAND ; echo exit ) | telnet host.com 80
Trying host.com
Connected to host.com
Escape character is '^]'.
where it breaks
Connection closed by foreign host.

I get immediately dropped (well, after the sleep 1). Any ideas why entering the command long-hand works but passing it via a pipe doesn't ? Even a simple "echo 'GET /'" doesn't work.

bulliver 01-19-2006 04:09 PM

Using a pipe in this context is simply sending bunk input to telnet. You need to use 'nc' (AKA netcat).
Code:

( sleep 1 ; echo $DOMAIN_COMMAND ; echo exit ) | nc host.com 80

michaelsanford 01-19-2006 04:20 PM

Thanks, I never thought of that !

I read a reply to someone asking how to log in automatically over telnet, and he used this method (i.e., my bad method) to enter username, password, etc. I guess it didn't work.


All times are GMT -5. The time now is 08:31 AM.