Skip to content

Instantly share code, notes, and snippets.

@ruanbekker
Created February 15, 2018 09:42
Show Gist options
  • Save ruanbekker/1c2f81fb953aed459fc28ab0c923e42f to your computer and use it in GitHub Desktop.
Save ruanbekker/1c2f81fb953aed459fc28ab0c923e42f to your computer and use it in GitHub Desktop.
Report Status Codes in Bash
#!/bin/bash
#set -e
python -c "import $1" > /dev/null 2>&1
code=$?
if [ $code == 0 ]
then
echo "good"
echo "Status Code: $code"
else
echo "bad"
echo "Status Code: $code"
exit 1
fi
## ./report_status.sh foobar
# bad
# Status Code: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment