Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 578
knittl Avatar asked Apr 14 '10 17:04

knittl


People also ask

Can we transfer files through telnet?

To log on to an Internet server and look at information there, you use the telnet protocol. For example, you use telnet to log on to the library's server. You cannot download or upload files using telnet. To download or upload files, you use the File Transfer Protocol (FTP).


1 Answers

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/

like image 70
chetan Avatar answered Sep 20 '22 13:09

chetan