Skip to content

Instantly share code, notes, and snippets.

@reillysiemens
Last active February 15, 2021 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reillysiemens/7e9aea30417d28c8f59abadcd5561306 to your computer and use it in GitHub Desktop.
Save reillysiemens/7e9aea30417d28c8f59abadcd5561306 to your computer and use it in GitHub Desktop.
Check which WWU CS professors have facultyweb sites.
#!/bin/sh
FACULTYWEB='https://facultyweb.cs.wwu.edu/'
PROF_DIRECTORY='https://cs.wwu.edu/faculty'
USERNAME_PATTERN='<h2 class="title no-margin"><a href="/\K\w+'
PROFS=$(curl -s ${PROF_DIRECTORY} | grep -oP "${USERNAME_PATTERN}")
PADDING=$(for p in $PROFS; do echo $p | wc -c; done | sort | tail -1)
red () {
printf "\e[0;31m${1}\e[0;0m"
}
green () {
printf "\e[0;32m${1}\e[0;0m"
}
test_for_page () {
username=$1
url="${FACULTYWEB}~${username}/"
suffix=$(red "✘")
if curl -s --fail -L --head ${url} > /dev/null; then
suffix="$(green "✔") (${url})"
fi
printf "%*s ${suffix}\n" "$PADDING" "${prof}"
}
test_pages () {
for prof in ${PROFS}
do
test_for_page ${prof} &
done
}
test_pages | sort
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment