You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Princeton/pu-check-website

30 lines
798 B
Bash

#!/bin/sh
#
# curl -c /tmp/cookie.txt --location -k "https://oampfsqual.princeton.edu:443/psp/pfsqual/EMPLOYEE/ERP/" | grep "Central Authentication Service"
http="http"
uri=""
search=""
host=""
while [ -n "$1" ]; do
case "$1" in
-S) http="https"; shift 1;;
-H) host="$2"; shift 2;;
-u) uri="$2"; shift 2;;
-s) search="$2"; shift 2;;
*) shift 1;;
esac
done
tmpfile="/tmp/cookies.txt.$$"
rm -Rf $tmpfile
curl --silent -c $tmpfile --location -k "$http://$host$uri" > $tmpfile.output
[ $? -ne 0 ] && echo "WARNING: $http://$host$uri did not respond properly" && exit 1
if [ -n "$search" ]; then
grep -q "$search" $tmpfile.output
[ $? -ne 0 ] && echo "CRITICAL: Cannot find $search in $http://$host$uri" && exit 2
echo "OK: Found $search in $http://$host$uri"
fi
exit 0