mirror of
https://github.com/adulau/scripts.git
synced 2024-12-03 15:37:17 +00:00
new: [url-check] Read a list of URLs from stdin and print if the url is Ok (200 or 301 with one redirect to a 200)
This commit is contained in:
commit
0a4043af39
1 changed files with 16 additions and 0 deletions
16
url-check.sh
Normal file
16
url-check.sh
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Read a list of URLs from stdin and print if the url is Ok (200 or 301 with one redirect to a 200)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
while read line
|
||||||
|
do
|
||||||
|
status_code=$(curl --write-out %{http_code} --max-redirs 1 --silent --output /dev/null -H "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0" -m 2 -s --head --request GET -L ${line})
|
||||||
|
if [[ "$status_code" -ne 200 ]] ; then
|
||||||
|
echo "Nok (${status_code}): ${line}"
|
||||||
|
else
|
||||||
|
echo "Ok (${status_code}): ${line}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in a new issue