精典shell源码(1)

#!/bin/tcsh -f
# Gnu TC shell
# The Party Program--Invitations to friends from the "guest" file
set guestfile = ./guests  #  ~/shell/guests
if ( ! -e "$guestfile" ) then
 echo "$guestfile:t non-existent"
 exit 1
endif
setenv PLACE "Sarotini's"
@ Time = `date +%H` + 1
set food = ( cheese crackers shrimp drinks "hot dogs" sandwiches )
foreach person ( `cat $guestfile` )
 if ( $person =~ root ) continue
        # Start of here document
 mail -v -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 $food[1] and
 anything else you would like to eat? Let me know if you can't
 make it. Hope to see you soon.
  Your pal,
      ellie@`hostname` # or `uname -n`
FINIS
 shift food
 if ( $#food ==  0 ) then
   set food = ( cheese crackers shrimp drinks "hot dogs"
  sandwiches )
 endif
end
  
echo "Bye..."

你可能感兴趣的:(精典shell源码(1))