Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- :<<israeltorres_comment_block
- ./check-wa-appid.sh
- Israel Torres
- 2012-03-20
- checks the validity of a wolframalpha appid(key)
- Mac OSx 10.7.3 11DS0d
- Darwin Kernel Version 11.3.0
- GNU bash, version 3.2.48(1)-release
- israeltorres_comment_block
- #required app check
- RQDAPP='curl'
- hash $RQDAPP 2>&- || { echo >&2 "$RQDAPP binary not found - aborting"; exit 1; }
- #
- if [ ! $# -lt 1 ]; then
- APPID=$1
- MYDATE=$(date +%s)
- TSTQRY=$(curl -s 'http://api.wolframalpha.com/v1/query?input=day+of+the+week&appid='$APPID)
- TSTDAY=$(date '+%A')
- TSTTWO=$(echo "$TSTQRY" | grep plaintext -m 2 | sed "s/\plaintext\>//g' | sed 's/\<\/plaintext\>//g' | grep -v \| | sed 's/^ *//g')
- TESTONE=$(echo $TSTQRY | grep -v -q '<error> <code>1</code> <msg>Invalid appid</msg> </error>')
- if [ $? -ne 0 ]; then
- echo -e "$MYDATE\t$APPID\tINVALID"
- else
- if [ "$TSTTWO" = "$TSTDAY" ]; then
- echo -e "$MYDATE\t$APPID\tVALID"
- else
- TSTBLK=$(echo $TSTQRY | grep -v -q '<error> <code>10</code> <msg>Account blocked</msg> </error>')
- if [ $? -ne 0 ]; then
- echo -e "$MYDATE\t$APPID\tBLOCKED"
- else
- echo -e "$MYDATE\t$APPID\tEXCEPTION ENCOUNTERED:\n-----DUMP BEGIN----\n$TSTQRY\n----DUMP END----"
- fi
- fi
- fi
- else
- echo "usage: $0 'XXXXXX-XXXXXXXXXX'"
- echo "example: $0 XXXXXX-XXXXXXXXX"
- echo "batch: for x in \$(cat appid-list.txt; do ./check-wa-appid.sh \$x; done"
- fi
- #eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement