#!/bin/tcsh -f # # Create mythtv_contents_rec.YYMMDD files for preceding days. # Stop when a previous day already has a file. # (Also stop at 2010/05/03 since that was our first MythTV recording.) # It is assumed this will be run in the public webpages directory. (Mine is $home/webpages/bdchivers.) # # Brent Chivers 2010/July/12 ##! /bin/csh -fb # for setuid/setgid scripts (tsk) # set verbose # see commands before variable substitution # set echo # see commands after variable substitution unset histchars # get other users' history characters out of the way unalias * # get other users' .cshrc stuff out of the way ## set nonomatch # don't require wildcard matches # $0:t construction doesn't work! set cmd_name = $0 set cmd_name = $cmd_name:t # the name of this command set offset = -1 # always start with yesterday set ext = `$home/bin/date_name4 = $offset | /usr/bin/tr -d =` while ( ! -f mythtv_contents_rec.$ext ) if ( "$ext" < "20100503") then echo "$ext is before our MythTV epoch. Time to quit." exit (-1) endif echo "creating mythtv_contents_rec.$ext file...." # get yyyy-Month-dd date for offset ; drop "-" chars ; change 0d to leading blank ; chop Month to 3 chars -- use this for grep arg # grep for date in mythtv_contents and mythtv_deleted files (suppress file name) # sort by recording time (since grep was by date, all dates should be the same) /usr/bin/grep -h "`$home/bin/date_name3 $offset | /usr/bin/sed -e 's/-/ /g' -e 's/ 0/ /' -e 's/\([A-Z][a-z][a-z]\)[a-z]*/\1/'`" mythtv_contents mythtv_deleted | /usr/bin/sort -f -t' ' +4 > mythtv_contents_rec.$ext @ offset -= 1 # decrement counter set ext = `$home/bin/date_name4 = $offset | /usr/bin/tr -d =` end echo "mythtv_contents_rec.$ext file already exists. Done."