Send simple HTTP request with wget, curl, telnet and netcat

November 24th, 2016 by Alex Leave a reply »

I won’t say much, sometimes you just need to trigger a remote script or test if it works.

Here’s how to do that in command line.

1. wget

wget is a “a non-interactive network retriever” as described in the docs.

wget -q 'http://graphicmaniacs.com' > /dev/null

2. curl

curl is a “command line tool and library for transferring data with URLs”

curl -s 'http://graphicmaniacs.com' > /dev/null

And of course, if you want the commands to not output anything in case of error, append 2>&1 to the end of command

3. telnet

Telnet is another interesting approach in case you don’t have wget or curl, or you are on a limited system.

telnet graphicmaniacs.com 80
GET / HTTP/1.1
Host: graphicmaniacs.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36

Finish the telnet command with additional newline (hit enter again).

4. netcat or nc

This is another way to do it. Depending on the release, you could have “netcat” or “nc”, so check your system which one you have

printf "GET / HTTP/1.0\r\nHost: graphicmaniacs.com\r\n\r\n" | nc graphicmaniacs.com 80

Comments are closed.