procmail
[Top] [All Lists]

Re: Test if a file exist

2000-11-29 19:04:28
From: "Roberto Wagner" <rwagner(_at_)tecknowhow(_dot_)com>

This is a multi-part message in MIME format.

Please don't do that.



I want to test if a file exist to to make a decision.
I will need to creat a file in a certain moment too.


Have you read "man procmailex"?  Here is something close from
there by which you could easily extrapolate:


      . . .  if the `94-01' directory wouldn't have existed,  it
  is created automatically:

       MONTHFOLDER=`date +%y-%m`

       :0 Wic
       * ? test ! -d $MONTHFOLDER
       | mkdir $MONTHFOLDER

       :0:
       * meeting
       ${MONTHFOLDER}/meeting

  The same as above, but now by slightly different means:

       MONTHFOLDER=`date +%y-%m`
       DUMMY=`test -d $MONTHFOLDER || mkdir $MONTHFOLDER`


So taking a cue from the above, you could test/create a file thus:

        :0 Wi
        * ? test ! -f myfile
        {
           # if we're here, `myfile' did not exist
           :0 c  # so let's create it
           | touch myfile

           :0
           | do-something
        }

        :0 E  # else, if it existed . . . .
        | do-something-else

-- 
Netcom has imploded.  Please now use NOTnetcom.com for mail.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Ex-Netcommies:  Mail "forwards" for free forwarding service!
NOT affiliated with EarthLink, Inc.'s Netcom brand identity.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>