Last active
June 18, 2018 11:33
-
-
Save aozimkov/ae9955d735eb1e08a8a61f2c066606a7 to your computer and use it in GitHub Desktop.
Simple bash script checks http 200 response code for urls from file
This file contains 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 | |
## This script simply gets a line (with url) from | |
## the file setted as parameter and checks its url | |
## response code | |
## | |
## example: ./script.sh urls.txt | |
## | |
## https://github.com/aozimkov | |
## | |
## ************************************************* | |
checker(){ | |
RESPONSE_CODE=$(curl --write-out %{http_code} --silent --output /dev/null $1) | |
CODENUM=$2 | |
if [ "$RESPONSE_CODE" != "$CODENUM" ]; then | |
echo "$LINE : $CODENUM" | |
fi | |
} | |
if [ -z $2 ]; | |
then | |
CODE=$2 | |
else | |
CODE=200 | |
fi | |
while read LINE; do checker "$LINE" "$CODE"; done < $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment