#!/usr/bin/bash # # Original version from Quigley's UNIX SHELLS by EXAMPLE, #2.7 # Last revised by Brian D. Davison, 1 March 2007 # Gnu bash versions 2.x # The Party Program--Invitations to friends from the # "guest" file guestfile=./guests mail=/usr/ucb/mail if [[ ! -e "$guestfile" ]] then printf "${guestfile##*/} non-existent" exit 1 fi export PLACE="Packard Lab Lobby" #declare -i Time=14 (( Time=$(date +%H)+1 )) if (( $Time > 12 )) then (( Time = $Time - 12 )) fi declare -a foods=(cheese crackers shrimp drinks '"hot dogs"' sandwiches pizza) declare -i n=0 for person in $(cat $guestfile) do if [[ $person == root ]] then continue else # Start of here document $mail -s "Party" $person <<- FINIS Hi $person! Please join me at $PLACE for a party! Meet me at $Time o'clock. I'll bring the ice cream. Would you please bring ${foods[$n]} and anything else you would like to eat? Let me know if you can make it. Hope to see you soon. Your pal, Prof D@$(hostname) FINIS n=n+1 if (( ${#foods[*]} == $n )) then n=0 fi fi done printf "Bye...\n"