Connecting to website without curl or bash Connecting to website without curl or bash curl curl

Connecting to website without curl or bash


  1. nc opens a connection to port 80 on google.com
  2. The echo statement is a valid GET request, using HTTP/1.0 protocol
  3. > /dev/null 2>&1 redirects both stdout and stderr, producing no output
  4. You can tell success by the exit code, in $? (value of 0 means success)

You could write this shorter:

echo -e "GET /\n\n" | nc google.com 80

And more portable (without echo -e):

printf "GET /\n\n" | nc google.com 80

Or more portable but still with echo:

{ echo GET /; echo; } | nc google.com 80