#!/bin/bash ## ## Virginia General District Court online case information: find a person's ## cases, their status and hearings. https://eapps.courts.state.va.us/gdcourts/ ## The site's terms-of-use click-through is accepted for each session. ## CMD=$(basename $0) TMP=$HOME/.tmp/$CMD ; mkdir -p $TMP TENTEN_DIR=$(dirname "$(dirname "$(realpath "$0")")") LIBEXEC=$TENTEN_DIR/libexec/$CMD usage() { echo "Usage: $CMD -a courts [-v] # name|fips" echo "Usage: $CMD -a search -c court -l last [-f first] [-V] [-H] [-v] # case|name|hearing_date|hearing_time|charge|note" echo "Usage: $CMD -a case -c court -l last [-f first] -i case-number [-V] [-v] # section|label|value, then hearing|date|time|result|type|courtroom|plea|continuance" echo "Usage: $CMD -a jail -c county -l last [-f first] [-v] # inmate|label|value, booking|label|value, bond|type|amount, court|date|court," echo " # charge|description|offense_date|docket|disposition|disposition_date|sentence" echo "" echo " -c court FIPS code (013) or a name fragment (arlington, fairfax-county); for jail, a county with" echo " a reader in libexec/$CMD/jail/ (arlington)" echo " jail lists only people in custody right now: no output means not held there today" echo " -l/-f last and first name; the case action needs the name that found the case" echo " -i case number as search prints it (GC26000000-00)" echo " -H include archived cases (default: current only)" echo " -V civil cases (default: traffic/criminal)" echo " -v raw JSON instead of |-delimited output" exit 1 } unset ACTION COURT LAST FIRST CASE ARCHIVED CIVIL VERBOSE while getopts ":a:c:l:f:i:HVvh" o; do case "$o" in a) ACTION=$OPTARG ;; c) COURT=$OPTARG ;; l) LAST=$OPTARG ;; f) FIRST=$OPTARG ;; i) CASE=$OPTARG ;; H) ARCHIVED=--archived ;; V) CIVIL=V ;; v) VERBOSE=--verbose ;; *|h) usage ;; esac done ## Runs the PHP client with a throwaway cookie jar; remaining args are its options. court_site() { local jar jar=$(mktemp $TMP/jar.XXXXXX) php "$LIBEXEC/courtassist.php" --jar "$jar" --division "${CIVIL:-T}" $VERBOSE "$@" local status=$? rm -f "$jar" return $status } case "$ACTION" in courts) court_site --action courts ;; search) [ -z "$COURT" ] || [ -z "$LAST" ] && usage court_site --action search --court "$COURT" --last "$LAST" --first "${FIRST:-}" $ARCHIVED ;; case) [ -z "$COURT" ] || [ -z "$LAST" ] || [ -z "$CASE" ] && usage court_site --action case --court "$COURT" --last "$LAST" --first "${FIRST:-}" --case "$CASE" ;; jail) [ -z "$COURT" ] || [ -z "$LAST" ] && usage county=$(echo "$COURT" | tr 'A-Z' 'a-z') reader="$LIBEXEC/jail/$county.php" if [ ! -f "$reader" ]; then echo "No jail lookup for $county; available: $(ls "$LIBEXEC/jail" | sed 's/\.php$//' | paste -sd' ' -)" >&2 exit 1 fi php "$reader" --last "$LAST" --first "${FIRST:-}" $VERBOSE ;; *) usage ;; esac