I had some web server acting funny the other day so I decided to go Rambo style and get a page manually using telnet. I also wanted to save the output of the entire client/server negotiation for later analysis.
The Unix command script is just for that, it will run telnet (or any other shell command) for you and and allow you to work with it while capturing the standard input and output.
$ script -c "telnet www.aviran.org 80" output.txt Script started, file is output.txt Trying 22.214.171.124... Connected to www.aviran.org. Escape character is '^]'. GET / HTTP/1.1 HOST: www.aviran.org [Hit Enter Twice] . . THE WEB SERVER OUTPUT THE REQUESTED WEBPAGE . INCLUDING HEADERS . Connection closed by foreign host. Script done on Thu 15 Dec 2011 11:23:14 AM IST $
After running script with the appropriate parameters, telnet connects to the server. Lines 7-9 are what I send to the server in order to fetch the root HTML page (You have to hit enter twice to end the input).
When telnet ends, the output.txt file will contain the entire input and output that was send to and from telnet.