views:

62

answers:

2

hello community,

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?

A: 

I don't know if that's possible with telnet. Have you looked at netcat?

amertune
+1  A: 

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/

chetan
how can i get output back? i need the http/html response
knittl
The response will just show up on the stdout of the commandline.
chetan
it does when i enter the request on stdin, but when doing `nc < file` it will not display anything (although the request seems to have worked)
knittl