A mini-vacation program (unix utility), mail manipulator 
Author Message
 A mini-vacation program (unix utility), mail manipulator

I welcome comments.  I haven't looked at other programs that do this.
Maybe I should. Hope it is useful....
-prashant

#! /usr/local/bin/perl

##################################################################
# This little script is a mini-vacation program.
# Basically, when you go away, and your mailbox is filling up,
# you want to notify the poor souls waiting for
# you to reply that you won't be around for a while.
# This script replies to their mail automatically, assuming
# you have set up your .forward file correctly.
# Your $HOME/.forward file entry might look like:
# \prosh,"/usr/local/vacay -s -i"
# In this example, the vacay program will send the "internal"
# built-in message and append your $HOME/.signature file for
# the user named "prosh".
# This script only reads your mailbox, it doesn't alter or delete
# anything.
# You can change the builtin message below (see it?).
# You can also add other little appendages to your message,
# by placing a "print MAIL stuff;" command where the label
# INSERT is  in the program below.
# You would have to add a flag, look at $fortuneflag for example.
# I have adapted this code to do neat stuff like mail exploding
# (uh, mailing lists), ftpmailserver, guessing-game server using the
# subject line, etc etc etc
#
# BUGS: The message header parser part is not perfect.
#       I haven't really look at the header manipulating scripts
#       out there. I am sure there are faster better ways.
#       Hey, but let's say this is educational.
# BUGS: This should run on most Unixes :)
# DISCLAIMER: If this blows up your computer, it's not my fault!
# LICENSE: Poetic. If you are going to use this, and least send
# me a thank you note.
##################################################################
$user=$ENV{'USER'};

        $i eq "-s" && ($sigflag=1);
        $i eq "-i" && ($internalflag=1);
        $i eq "-f" && ($fortuneflag=1);
        if ($i eq "-h") {
print <<EOF;

Usage: $0 [-i] [-s] [-v] [-h]

where

-i    Sends the built-in vacation message.
-s    Sends your \$HOME/.signature file if it exists.
-f    Add a fortune! (assumes /usr/games/fortune exists.)
-h    Prints this help text.

EOF
exit;
        }

Quote:
}

$/="\n\n"; # magic?
while (<STDIN>) {

if (/\nFrom: / && /\nSubject: / && /\nTo: /) {
$header = $_;
$leftovers .= $lastmessage;
$lastmessage = $_;

Quote:
} else {$lastmessage .= $_;}
}

if ($header =~ /\nFrom:.+<[ ]*(.+)[ ]*>/) {
        $from =$1;
        } else {
                $header =~ /\nFrom:[ ]+([^ ]+)[ ]+/;
                $from = $1;
                }
$header =~ /\nSubject: (.*)\n/;
$subject = $1;

open(MAIL,"| mail -s Automatic-reply $from");

if (($internalflag == 0) && -e "$ENV{'HOME'}/.vacation.msg") {
        print MAIL `cat $ENV{'HOME'}/.vacation.msg`;
        } else {
print MAIL <<EOF;

A message brought to you by my friendly answering service:

I am on vacation right now.
I'll read the message you have sent as soon as I get back.

Love,
me

EOF

Quote:
}

if (($sigflag == 1) && (-e "$ENV{'HOME'}/.signature")) {
        print MAIL `cat $ENV{'HOME'}/.signature`;
        }

if (($fortuneflag == 1) && (-e "/usr/games/fortune")) {
        print MAIL "\n-------\n",`/usr/games/fortune -s`;
        }

$subject =~ /cranberri/i && print MAIL "\n--\nI like the Cranberries too!\n";

INSERT: #insert yer own home-brewed text spewer here....

close(MAIL);

--

   `_     _   _
prasant inamati
--------------------------------------------------------
There is no reason for any individual to have a computer
in their home. --Ken Olsen, 1977
--------------------------------------------------------



Sat, 18 Oct 1997 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Need a vacation program that is really smart about mailing lists

2. Wanted: perl scripts to emulate cut and paste (Unix utility programs)

3. vacation program

4. vacation program in perl?

5. Vacation program in Perl

6. vacation program in perl

7. Question on Perl program, vacation.

8. Need vacation program in Perl!

9. Vacation program

10. MANCGI: a centralized multi hosts unix MAN cgi utility

11. Counting characters with unix utilities

12. Counting characters with Unix utilities

 

 
Powered by phpBB® Forum Software