Search code examples
httphttp-redirectpipetelnet

how to feed a file to telnet


trying to understand http and headers i was playing around with telnet to send requests. to not type everything again and again and again i thought i'd write a small textfile with all the commands i need.

my file is as simple as follows:

GET /somefile.php HTTP/1.1
Host: localhost

i then try to feed it to telnet with io-redirection:

$ telnet localhost 80 < telnet.txt

but all output i get is

Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

what am i doing wrong?


Solution

  • telnet is not the right tool for this job. Try :

     netcat localhost 80 < telnet.txt
    

    btw, if you don't have the tool installed on your machine, you can get it here:

    http://netcat.sourceforge.net/