#!/bin/sh # creates the allgrade shell script to send grades to a class # Has one parm $1: the file containing student names, userids and # email addresses, one student per line, e.g.: # turing aturing@erols.com Alan Mathison Turing # creates a shell script in the current directory # Bill Bynum # August 1998 pgmname=`basename $0` sname=allgrade usage(){ echo 'Usage: '$pgmname' [ -f scriptname ] name_list_file' echo " 'scriptname' is the name of the script to be produced" echo " default is \"$sname\"" echo " 'name_list_file' is a file containing student e-mail addresses and" echo " names, one per line. Each line is expected to be of the form" echo " login_id email_address Name" echo " turing aturing@erols.com Alan Mathison Turing" echo " Everything after the e-mail address is treated as the last name" echo " The first line of the namelist file is used for the class title" } case $1 in "") usage exit;; esac clabel= while true do case $1 in -f) sname=$2 shift shift;; *) break;; esac done case $1 in "") echo "Name of file containing student names and login id's is required!" usage exit;; esac if (test ! -f $1) then echo "The file \"$1\" does not exist!" exit fi case $CLASSTITLE in "") CLASSTITLE=`head -1 $1 |sed 's/#[ /t]*//'` ;; esac if (test -f $sname) then rm -f $sname fi echo '#!/bin/sh' > $sname echo "# Created by `basename $0` from $1 `date`" >> $sname echo 'BYNUMBIN=/home/f85/bynum/bin' >> $sname echo 'sysbin=/bin:/usr/bin:/usr/local/bin:/usr/lib' >>$sname echo 'otherbin=$HOME/bin:$BYNUMBIN:$BYNUMBIN/i586' >>$sname echo 'PATH=$sysbin:$otherbin:.' >> $sname echo "classtitle=\"$CLASSTITLE\"" >> $sname echo 'debug=' >> $sname echo 'listflag=' >> $sname echo 'msglag=' >> $sname echo 'while true' >> $sname echo 'do' >> $sname echo ' case $1 in' >> $sname echo ' "-d") debug="-d"' >> $sname echo ' shift;;' >> $sname echo ' "-l") listflag="-l"' >> $sname echo ' shift;;' >> $sname echo ' "-m") if (test ! -f $2) then' >> $sname echo ' echo "Message file \"$2\" does not exist!"' >> $sname echo ' exit' >> $sname echo ' fi' >> $sname echo ' msgflag="-m $2"' >> $sname echo ' shift' >> $sname echo ' shift;;' >> $sname echo ' *) break;;' >> $sname echo ' esac' >> $sname echo 'done' >> $sname echo 'case $listflag in' >> $sname echo ' -l) cat /dev/null > listing.out' >> $sname echo ' ;;' >> $sname echo 'esac' >> $sname awk ' $1 ~ /#/ || $1 ~ /^$/ $1 !~ /#/ && $1 !~ /^$/ { printf("mailgrades '\$'debug '\$'msgflag '\$'listflag \"") for (i = 3;i <= NF-1; i++) printf("%s ",$i) printf("%s",$NF) printf("\" %s \"$classtitle\"\n",$2) } ' $1 >> $sname echo 'echo all grades sent' >> $sname echo Make $sname executable ... chmod 700 $sname # # $Id: makeallgrade,v 1.10 2005/09/20 13:21:47 bynum Exp $ #