Created
December 22, 2015 16:55
-
-
Save cbarraco/109b28860f940843ced8 to your computer and use it in GitHub Desktop.
HTTP Client written in BASH via http://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
exec 3<> /dev/tcp/${1:-www.cyberciti.biz}/80 | |
printf "GET / HTTP/1.0\r\n" >&3 | |
printf "Accept: text/html, text/plain\r\n" >&3 | |
printf "Accept-Language: en\r\n" >&3 | |
printf "User-Agent: nixCraft_BashScript v.%s\r\n" "${BASH_VERSION}" >&3 | |
printf "\r\n" >&3 | |
while read LINE <&3 | |
do | |
# do something on $LINE | |
# or send $LINE to grep or awk for grabbing data | |
# or simply display back data with echo command | |
echo $LINE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment