Last active
April 13, 2021 06:39
-
-
Save jplomas/0fd17e51f2be1067a326e084ee666b4f to your computer and use it in GitHub Desktop.
Shell script to validate GMC number
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/sh | |
if [ $# -eq 0 ]; then | |
echo "No argument (GMC number) provided" | |
exit 1 | |
fi | |
RES=$(cURL -s https://www.gmc-uk.org/doctors/$1 | grep -A2 "<div class=\"c-dr-details__status-description\">" | grep -E ' {20,}' | sed -e 's/^[ \t]*//') | |
if [ -z "$RES" ]; then | |
echo "Not found" | |
exit 1 | |
else | |
echo $RES | |
fi | |
if [[ $RES == *"Not Registered"* ]]; then | |
exit 1 | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated with exit codes and correct shell specifier 🤦♂️