procmail
[Top] [All Lists]

Problem With Email File Fetching Recipe

1996-05-19 15:01:05
    I have the following recipe which is supposed to allow others to
fetch files from my ftp library by email simply by using a Subj: of

        get file {whatever}

If the file (all are DOS files) has any of certain extensions, it will
be uuencoded first.  (Note that variables DIRMAIL, VERBOSITY, and
LOGGING are set before this recipe is entered, and the little shell
script binfiletest is hard wired and marked executable.)

# ====================== getstuff.rc ======================
# ========== automatically send a specified file ==========
# ========= format -- Subject: get file {filename} ========
# ======== multiple spaces allowed in Subject line ========
# ===== filenames alphanumeric _.- (but no dot files) =====
# =========================================================

# Directory for files available by email
FTP_LIB=/ftp/pobart

# Turn on logging so we know if anyone is requesting files
VERBOSE=off
LOGABSTRACT=yes

:0
* ^Subject: +get +file +[0-9A-Za-z_]
* !^X-Loop: $MY_ADDR
* !^Subject:.*Re:
* !^FROM_DAEMON
* !^Precedence: *junk
* !^Subject +get +file +.*[/.]\.
{

  WHOFROM=`formail -xFrom:`  # Whom did this request come from?

  :0 fhw                # Reverse mailheader and extract name
  * ^Subject: +get +file +\/[-0-9A-Za-z_.]+
  | formail -rA "From: $MY_ADDR" -A "X-Loop: $MY_ADDR" -A "Precedence: junk"

  MAILDIR=$FTP_LIB      # chdir to fileserver directory

  FILE="$MATCH"         # The requested filename

  # Log the requestor (splitting "" lines is deliberate)
  LOG="$WHOFROM
"

  :0 ah                 # Send the file according to file type
  {
     #*********************************************************
     # binfiletest is a shell script to test whether an ftp-lib
     # file is binary and therefore must be sent UUENCODEd.
     # Update if new binary file types are added.
     #*********************************************************
     :0 hw              # Is it a binary file request?
     * ? $HOME/bin/binfiletest $FILE
     | ( cat -; uuencode ./$FILE $FILE ) | $SENDMAIL -oi -t

     :0 h               # If not binary, send a text file
     | cat - ./$FILE 2>&1 | $SENDMAIL -oi -t
  }

  # Reset to our usual mail directory
  MAILDIR=$DIRMAIL

}

# Reset logging to what it normally is for procmail
VERBOSE=$VERBOSITY
LOGABSTRACT=$LOGGING


#************************************************
# binfiletest
# Shell script to test whether an ftp-lib file is
# binary and therefore must be sent UUENCODEd
# Exit: 0 for binary files; 1 for text files
#************************************************

##!/bin/sh
#case $1 in
#*.zip|*.exe|*.com|*.gif|*.jpg) exit 0;;    # binary files
#esac
#exit 1

    This recipe works fine when *I* try to fetch a file from my own
library.  However, earlier today, someone else tried it, and the log
clearly showed a failure:

procmail: Couldn't chdir to "/ftp/pobart"
 $$$$$(_at_)ix(_dot_)netcom(_dot_)com (############### )  <--- userid concealed
uuencode: ./sled11.zip: No such file or directory
 Subject: Re: get file sled11.zip
  Folder:  ( cat -; uuencode ./$FILE $FILE ) | $SENDMAIL -oi -t             254

Obviously, if the chdir to the ftp lib directory failed, the file would
not be found.  Any clues as to what is wrong?  (BTW, the directory
/ftp/pobart has 755 permissions.)  As I say, it works for me -- I just
tried it.

Thanks much.
Paul                             <pobart(_at_)access(_dot_)digex(_dot_)net>
----------------------------------------------------------
Paul O. Bartlett, P.O. Box 857, Vienna, VA 22183-0857, USA
Finger, keyserver, or WWW for PGP 2.6.2 public key 
Home Page:  URL: http://www.access.digex.net/~pobart     

<Prev in Thread] Current Thread [Next in Thread>
  • Problem With Email File Fetching Recipe, Paul O Bartlett <=