Difference between revisions of "T1042 CLI Script"

From CDOT Wiki
Jump to: navigation, search
Line 31: Line 31:
 
The data displayed is taken from the [[Meeting Room T1042]] page on this wiki, and the date and times must be formatted correctly (YYYY-MM-DD HH:MM-HH:MM) to display.
 
The data displayed is taken from the [[Meeting Room T1042]] page on this wiki, and the date and times must be formatted correctly (YYYY-MM-DD HH:MM-HH:MM) to display.
  
 +
<!-- THE CODE BELOW MAY PREVENT LINES FROM APPEARING IF THEY HAVE UNLINKED OR MISSING CONTACT DATA -- *FIXME*
  
 
If interested in the contact person as well, replace the last sed line with
 
If interested in the contact person as well, replace the last sed line with
 
  sed -n "s|<tr><td>$(date +%Y-%m-%d -d "$*") \([0-2][0-9]:[0-5][0-9]-[0-2][0-9]:[0-5][0-9]\)</td><td>\([^<]\+\)</td>.*>\([^<]\+\)</a>.*$| \1  \2  \t \3 |p"|
 
  sed -n "s|<tr><td>$(date +%Y-%m-%d -d "$*") \([0-2][0-9]:[0-5][0-9]-[0-2][0-9]:[0-5][0-9]\)</td><td>\([^<]\+\)</td>.*>\([^<]\+\)</a>.*$| \1  \2  \t \3 |p"|
 +
 +
-->

Revision as of 23:15, 6 May 2016

This is a bash script to display the t1042 bookings for a given day:

#!/bin/bash
#
# Script to display bookings in T1042.
# Give a datespec on the command line, or no args for today.
#
# CTyler 2015-05-13
#

echo "T1042 schedule for $(date +%Y-%m-%d -d "$*"):"

curl http://zenit.senecac.on.ca/wiki/index.php/Meeting_Room_T1042 2>/dev/null|
egrep "</?td|</?tr"|tr -d "\012"|
sed "s|</tr><tr>|</tr>\n<tr>|g"|
sed -n "s|<tr><td>$(date +%Y-%m-%d -d "$*") \([0-2][0-9]:[0-5][0-9]-[0-2][0-9]:[0-5][0-9]\)</td><td>\([^<]\+\)</td>.*$|  \1 \2|p"|
sort

To use this script, run it with no arguments for the current day, or specify a day:

t1042
t1042 tomorrow
t1042 yesterday
t1042 next friday
t1042 next week friday
t1042 last tuesday
t1042 may 15
t1042 2016-02-01
t1042 june 7, 2018

The data displayed is taken from the Meeting Room T1042 page on this wiki, and the date and times must be formatted correctly (YYYY-MM-DD HH:MM-HH:MM) to display.