home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / unix_c / mail / vacation.sh < prev    next >
Encoding:
Text File  |  1989-03-21  |  3.2 KB  |  92 lines

  1. 19-Dec-85 00:18:00-MST,3330;000000000001
  2. Return-Path: <unix-sources-request@BRL.ARPA>
  3. Received: from BRL-TGR.ARPA by SIMTEL20.ARPA with TCP; Thu 19 Dec 85 00:17:54-MST
  4. Received: from usenet by TGR.BRL.ARPA id a007919; 19 Dec 85 1:47 EST
  5. From: Eric Mazur <mazur@harvard.uucp>
  6. Newsgroups: net.sources
  7. Subject: vacation.sh
  8. Message-ID: <558@harvard.UUCP>
  9. Date: 18 Dec 85 21:39:58 GMT
  10. Keywords: mail-answering, vacation, shell script, Venix
  11. To:       unix-sources@BRL-TGR.ARPA
  12.  
  13. A little while ago I requested from the net a program to answer incoming
  14. mail during my absence (No, I don't have sendmail; can't use .forward...).
  15. Since I received no reply, I started writing my own little shell script.
  16. Even though I probably re-invented the wheel, it was nice, and I think the
  17. result is neat! Besides, some people might not have seen this wheel yet.
  18. So here we go. The header explains it all. Happy holidays!
  19.  
  20. Eric Mazur
  21.  
  22. P.S.:    I would very much appreciate receiving any comments, suggestions,
  23.     improvements and bug reports you have. It runs fine on Venix/PRO,
  24.     so (with all respect for Venix) it should really work on any
  25.     other Unix version.
  26.  
  27. ARPA-NET:    mazur@harvard.harvard.EDU
  28. BITNET:        mazur@harvunxh.bitnet
  29. UUCP:                             /-----    mazur
  30.                              /  /---    dasy!mazur
  31. {seismo,harpo,ihnp4,linus,allegra,ut-sally}!harvard! ------
  32.                             \  \___    lasex!mazur
  33.                              \_____    molphy!mazur
  34.  
  35. ------------------------------- vacation(.sh) ---------------------------------
  36. : Shell script to answer your mail while you are gone. Will only work on
  37. : Usenet, probably not to other networks. Will not work if you don't have
  38. : the UCB "from" utility. You might try "grep From" on your mailbox instead,
  39. : but that is not water-tight.
  40.  
  41. : USAGE:
  42. : 1. Put a ".vacation" note in your home directory - this is the file that
  43. :    is going to be sent in reply to your incoming mail.
  44. : 2. Type "vacation [-c]" and have a nice vacation. The -c option will
  45. :    cause the program to keep a ".vmbox.log" of answered mail.
  46. : 3. When you come back - heaven forbid - remove the ".vacation" file.
  47. : 4. Read your mail with "mail -f vmbox".
  48.  
  49. : AUTHOR: Eric Mazur, 17 December 1985 - about to leave for a vacation.
  50. :      Mail improvements and bugs to: mazur@harvard.uucp
  51.  
  52. : BUG: Relies heavily on the fact that the basename of your home directory
  53. :      is the same as your login name, but unfortunately "who am i"
  54. :      yield the desired answer when executed by "at".
  55.  
  56. case $1 in
  57. "")    ;;
  58. -c)    check=1 ;;
  59. *)    echo Usage: vacation [-c]; exit ;;
  60. esac
  61.  
  62. if test -f $HOME/.vacation        : vacation will die if file removed
  63. then
  64.     me=`basename $HOME`
  65.     mybox='/usr/spool/mail/'$me
  66.     to=`from | awk '{printf("%s ",$2)}END{printf("\n")}'`
  67.     cat $mybox >> $HOME/vmbox
  68.     cp /dev/null $mybox
  69.     mail -s "Re: Your message" $to < $HOME/.vacation
  70.     if test $check
  71.     then
  72.         /bin/echo -n "Replied to: $to on " >> $HOME/vmbox.log
  73.         date >> $HOME/vmbox.log
  74.     fi
  75.     echo vacation $1 | at 1am    : do it again tomorrow
  76.     exit
  77. else                    : vacation over; the boss is back
  78.     echo "Couldn't find $HOME/.vacation."
  79.     exit
  80. fi
  81.  
  82. -- 
  83. Eric Mazur
  84.  
  85. ARPA-NET:    mazur@harvard.harvard.EDU
  86. BITNET:        mazur@harvunxh.bitnet
  87. UUCP:                             /-----    mazur
  88.                              /  /---    dasy!mazur
  89. {seismo,harpo,ihnp4,linus,allegra,ut-sally}!harvard! ------
  90.                             \  \___    lasex!mazur
  91.                              \_____    molphy!mazur
  92.