Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mailproc(1) — UnixWare 2.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought






       mailproc(1)                                              mailproc(1)


       NAME
             mailproc - mail file processor

       SYNOPSIS
             mailproc -y
             mailproc [-alnoprsvV] [-f filename] [-c command-file] [-d directory]
                         [-e command-expression]

       DESCRIPTION
             The mailproc command is a utility that parses a mail format
             file into messages and then performs a set of tests on each
             message.  If a given test succeeds, the associated action is
             performed on the message.  The message is then removed from
             the mail file unless otherwise indicated.

             Each test and action pair comprises a mailproc command:

                         user:test:exit-code-specification:action

             The user field is used to  match  the  return  path  from  the
             message, as derived from the >From UNIX postmarks found in the
             message.  A null user field will match any message.  The  user
             field  is  a  regular  expression as used by egrep.  Thus, the
             string ihuge!.+ would match all  messages  sent  from  machine
             ihuge.

             The  test  field  specifies  the  UNIX  command   or   regular
             expression  match  to  be evaluated.  This test may access the
             whole message, the message text, and/or  values  of  the  mail
             header lines (see the section on Escapes, below).  The default
             test is true.  If the first character of the test field  is  a
             tilde  (~), then a regular expression match will be performed.
             The pattern which follows, up to the next  tilde,  is  matched
             against  the string after that, up to the following tilde.  An
             example   of   the   regular   expression   match   would   be
             ~%{From}~Clinton~  to  match  any  messages with a From header
             that has the string "Clinton" present.

             The exit-code-specification field specifies the disposition of
             the  message  after  the  action  command  is executed.  It is
             described further below.

             The action field specifies the UNIX command  to  be  evaluated
             upon success of the indicated test.  This action has access to
             all the information available to the test.  The default action
             is no action.


                           Copyright 1994 Novell, Inc.               Page 1













      mailproc(1)                                              mailproc(1)


            For a given message, mailproc will start at the  beginning  of
            the  command  list,  trying to match the return address of the
            message with the user field of  the  command.   If  the  match
            succeeds,  the  test  will be executed.  If the test succeeds,
            the action will be executed.  Failure of the match, the  test,
            or  the  action  will  cause  mailproc to continue to the next
            command.

            Once a message has  successfully  passed  the  action,  it  is
            marked  as  processed.  The determination of whether an action
            command succeeded or failed is determined  by  the  exit-code-
            specification.    Successfully   processed  messages  will  be
            removed from the mail file unless the exit code is marked as a
            continuation by the exit-code-specification.

            An exit-code-specification looks like:

                        S=ec;K=ec;C=ec;

            In each case, ec is a list of numbers or  ranges  of  numbers,
            separated  by commas, or the wild card *.  This is exactly the
            same as the exit codes used in personal surrogates (see  mail)
            and  the  mail  surrogate file (see mailsurr).  The exit codes
            following S= are used to indicate success, along with deletion
            of  the  message.   The  exit  codes  following K= are used to
            indicate success,  along  with  keeping  the  message  in  the
            mailfile.   The  exit  codes following C= are used to indicate
            continuation, causing further commands in the command list  to
            be   processed.    For   example,   the  following  exit-code-
            specification,

                        S=1-4,99;K=0,12;C=*;

            says that when the action command returns with the exit  codes
            of  1,  2,  3,  4  or  99,  the  message  is  to be considered
            successfully processed and removed from the mail  file.   When
            the action command returns with the exit codes of 0 or 12, the
            message is to be considered successfully processed,  but  kept
            in  the  mail  file.  When the action command returns with any
            other exit codes, the next command in the command list  is  to
            be processed.

            If one is not specified, the  default  exit-code-specification
            is:

                        S=0;C=*;


                          Copyright 1994 Novell, Inc.               Page 2













       mailproc(1)                                              mailproc(1)


             (The S=, K= and C= exit codes are looked at in that order.)

             When run on a mailbox, mailproc modifies any messages left  in
             the mailbox by adding a Status header with a value of F.

       ESCAPES
             mailproc commands support a number of %-escapes to make
             information available to the test and the action commands.
             The supported escapes are:

                   %d        Returns the message date string.

                   %!F,%@F   Returns the full from mail path in ! style and
                             @ style, respectively.

                   %f        Returns the portion of the from mail path
                             matching the user field.

                   %s        Returns the subject header of the message.

                   %m        Returns a filename containing just the body of
                             the message.

                   %M        Returns a filename containing the entire
                             message (headers and all).

                   %H        Returns a filename containing the message
                             header.

                   %string   Returns the value of the header named string.
                             (Only the first line of the first such header
                             is returned.)

                   %%        Returns a single %.  This escape must be used
                             if any %'s need to be included in the user,
                             test and action fields.

                   %:        Returns a colon.  This escape must be used if
                             any colons need to be included in the user,
                             test and action fields.

             In addition to these escapes, the action supports several
             special forms.  These special forms are used to aid in moving
             messages to files.




                           Copyright 1994 Novell, Inc.               Page 3













      mailproc(1)                                              mailproc(1)


                  %m> file  Place the message text in the file file.

                  %m>> file Append the message text to the file file.

                  %M> file  Place the full message (including headers) in
                            the file file.

                  %M>> file Append the full message (including headers) to
                            the file file.

      OPTIONS
            mailproc supports the following options:

                  -y        Install a personal mail surrogate that reads:
                            mailproc -p Note that this is equivalent to
                            running the command mail -F "|
                            S=0;C=1;F=*mailproc -p" and that the mailproc
                            options of -c, -d, -e and -f are passed along
                            as well.  To remove the personal mail
                            surrogate, execute the command: mail -F ""

                  -a        Process all messages in the mail file.  The
                            default is to process only the new messages.
                            A message is considered new if it does not
                            contain a Status: header, as put in by the
                            mailx(1) command or mailproc.

                  -l        Provide a list of the messages in the mail
                            file.  No further processing of the mail file
                            will be done.

                  -n        Indicate what action would be taken if
                            mailproc were executed without the -n option.
                            This option is similar to the -n option of
                            make(1).

                  -o        Send output from the test and action to
                            standard output.  The default is to redirect
                            stdout and stderr to /dev/null.

                  -r        Process the mailbox in read-only mode.  This
                            means that mailproc does all the specified
                            processing, including writing messages into
                            files, but the temporary processed mailbox is
                            not copied back into the mailbox.  Thus, when
                            run on a mailbox, the mailbox will not be


                          Copyright 1994 Novell, Inc.               Page 4













       mailproc(1)                                              mailproc(1)


                             changed (no messages will be removed and no
                             Status lines added).  When run on stdin, no
                             messages will be written to stdout.  This
                             option is useful for repetitive processing of
                             a mailbox.

                   -s        Read mail file input from stdin and write
                             output to stdout.

                   -p        This option is the same as the -s option
                             except that it assumes that the input is a
                             single message.  This option is intended for
                             use as a mail personal mail surrogate.

                   -v        Provide a verbose description of the operation
                             on a message by message basis.

                   -V        Print the mailproc version number.  No mail
                             file processing is done.

                   -f filename
                             Specifies the mail file from which input is to
                             be taken.  If this option is not specified and
                             the -s option is not used, the input file
                             defaults to the file indicated by the user's
                             MAIL environment variable.  If this variable
                             is unset or null, the input file is taken to
                             be /var/mail/$LOGNAME.  This option is ignored
                             if used with the -s option.

                   -c command-file
                             Specifies the file from which the commands are
                             to be read.  If this option is not specified
                             and the -e option is not used, the command
                             file defaults to the file indicated by the
                             MAILPROCRC environment variable.  If this
                             variable is unset or null, the input file is
                             taken to be $HOME/.mailproc_rc.

                   -e command
                             Specifies a mailproc command to be used.  This
                             option can be used to augment the commands
                             from a command file or it can be used alone.
                             Commands specified with the -e option are
                             executed before those in a specified command
                             file.  Multiple -e options may be specified.


                           Copyright 1994 Novell, Inc.               Page 5













      mailproc(1)                                              mailproc(1)


                  -d directory
                            Specifies the directory in which the commands
                            are to be executed.

      EXIT CODES
            When executed with the -p option, mailproc exits with a 0 if
            the message was successfully processed, a 1 if the message is
            to be left in the mailbox due to either a C= exit code or if
            none of the command actions match, and a 2 if there are any
            problems.

            When executed with the -y option, mailproc exits with a 0 if
            the mailbox was successfully updated, and non-zero otherwise.

            When executed without either the -p or -y options, mailproc
            exits with a 0 if the mailbox was successfully processed, and
            non-zero otherwise.

      EXAMPLES
            # list new messages in $MAIL
            #
            $ mailproc -l

            # list all messages in $MAIL
            #
            $ mailproc -la

            $ cat cmdfile1
            # Remove non-error line printer messages
            #
            lp:grep 'Job.*to printer'::
            $ mailproc -c cmdfile1

            $ cat cmdfile2
            # Automatically save messages about created MRs in
            # $HOME/mrs/mrlog
            #
            :grep 'MR.*created'::%m>>mrlog
            $ mailproc -c cmdfile2 -d mrs

            $ cat cmdfile3
            # Remove messages from UUCP uucleans
            #
            uucp:~uuclean ran~%s~::
            $ mailproc -c cmdfile3



                          Copyright 1994 Novell, Inc.               Page 6













       mailproc(1)                                              mailproc(1)


             $ cat cmdfile4
             # Warn me of messages from my_boss
             #
             my_boss::C=*;:echo "Mail from %f has arrived!!" | write me
             $ mailproc -c cmdfile4
             Message from user on system (tty001) [ Mon Feb 22 16:20:41 ] ...
             Mail from my_boss has arrived!!
             <EOT>

             $ cat cmdfile5
             # Automatic request processing, uses external
             # /bin/test process to execute test
             #
             :[ "%s" = "Request Document" ]::mail %@F < Doc_file
             $ mailproc -c cmdfile5

             # Print all the messages (old and new) from 'user1' in mailfile
             $ mailproc -a -f mailfile -e "user1::C=*:%M>/dev/tty"
                   ...
             $

             # Show the subject of all messages from the system foo
             $ mailproc -a -f mailfile -e "foo!*::C=*:echo '%f %s'>/dev/tty"
                   ...
             $

             # Print messages from 'user' in 'file' without changing 'file'
             $ mailproc -o -a -r -f file -e "user:::cat %M"
                 - or -
             $ mailproc -s -o -a -r -e "user:::cat %M" < file
                 - or -
             $ mailproc -s -a -e "user::C=*:" -e ":::" < file

             # Save all messages sent to net-dept
             $ mailproc -e ":grep '^To%:.*net-dept' %M::%M>>deptlog"
             $

             # install mailproc as a personal mail surrogate
             #    use $HOME/procmail/cmdfile as the command list
             #    and use $HOME/procmail as the save directory
             $ mailproc -y -c procmail/cmdfile -d procmail

       FILES
             $MAILPROCRC
                   Default location of the command file, mailproc.



                           Copyright 1994 Novell, Inc.               Page 7













      mailproc(1)                                              mailproc(1)


            $HOME/.mailproc_rc
                  Default location of the command file if MAILPROCRC is
                  unset or null.

            $MAIL Default location of the mail file.

            /var/mail/$LOGNAME
                  Default location of the mail file if $MAIL is unset or
                  null.

            $MAILPROCDIR
                  Directory in which the commands are to be executed.




































                          Copyright 1994 Novell, Inc.               Page 8








Typewritten Software • bear@typewritten.org • Edmonds, WA 98026