how to feed a file to telnet

The problem is that you feed all input to the telnet command instantly, without waiting for its output. Right after all of your input file has been fed, it will automatically cause telnet to "hang up", because the input stream reaches its end (EOF). Telnet might still be in its first millisecond or microsecond of actually waiting to establish a connection to the remote server when this happens. What you want to do is, send a command to telnet, then wait for it to do its job aka wait for the server's response, then send the next command, and so on, and only hang up at the very end when all the commands you sent were actually processed. To do this, use an 'expect' script instead of insta-feeding a text file. 'Expect' is the usual tool to do this job.


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/