Skip to content

Instantly share code, notes, and snippets.

@hughpearse
Created January 23, 2019 11:07
Show Gist options
  • Save hughpearse/28af1578a4f115d21046c56d8a186491 to your computer and use it in GitHub Desktop.
Save hughpearse/28af1578a4f115d21046c56d8a186491 to your computer and use it in GitHub Desktop.
Listen for any HTTP request
#!/bin/bash
port=$1
if [[ -n "$port" ]]; then
while true;
do
{ echo -e "HTTP/1.1 200 OK\r\n$(date)\r\n\r\n<h1>hello world from $(hostname) on $(date)</h1>" | nc -vl $port; }
done
else
echo "Usage: $(basename $0) <port>"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment