Open main menu

CDOT Wiki β

Changes

T1042 CLI Script

508 bytes added, 17:25, 12 February 2018
no edit summary
#!/bin/bash
#
# Script to display bookings in T1042./DB1042
# Give a datespec on the command line, or no args for today.
#
}
function check_day() {
date -d "$*" >&/dev/null
return $?
}
function usage() {
exec >&2
echo "Invalid dateSpecification."
echo "Usage: $(basename $0) [-w] dateSpecification"
echo "Where: dateSpecification is valid date (e.g., 2038-01-01 or Next Tuesday)"
echo " -w causes a full week to be output."
exit 1
}
if grep -qi t1042 <<<$0
then
ROOMNAME="DB1042" # new name
fi
trap "rm \$TEMPFILE" SIGHUP SIGINT EXIT
TEMPFILE=$(mktemp)
then
shift
if check_day "$*" then echo "${ROOMNAME} schedule for the week of $(date -d "$*" +%Y-%m-%d):" for X in {0..6} do echo date -d "$(( X - $(date +%w) )) day" +" %A:" show_day "$(date -d "$(date -d "$*") + $(( X - $(date +%w) )) day")" done doneelse usage exit 1 fi
else
if check_day "$*" then echo "${ROOMNAME} schedule for $(date +%Y-%m-%d -d "$*"):" show_day "$@" else usage exit 1 fi
fi
echo
rm $TEMPFILE
To use this script, run it with no arguments for the current day, or specify a day: