procmail
[Top] [All Lists]

Re: formail syntax use

1999-04-24 15:14:40
Abi Nelson wrote,

| I am trying to use formail to extract each mail message
| from a folder and save them to a seperate file or
| pipe it into a mail program that will mail each message to
| a new recipient.
| I have written a korn shell script but cannot seem to split
| the files.
| How do I use formail to split the file and save them as a
| seperate file to be piped into a mail program of my choice.
| 
| I tried
| formail -s < mail_folder > AA.$$
| This I thought should at least put the first message in
| this file but it put the whole folder messages in the AA.$$
| file.
| What am I missing?

What you're missing is the parsing order.  ksh replaces $$ with the process
ID of the calling shell before starting formail, so $$ has the same value
unchanging, and you essentially are accomplishing the same as

  cp mail_folder AA.$$

This worked for me:

  formail -s procmail -m MAILDIR=. DEFAULT='AA.$$' /dev/null < mail_folder

Note the strong quotes around $$.  That way they get passed literally to
procmail, and each procmail process forked by formail substitutes its own
PID.  I guess you could use -ns safely there instead of -s; I normally shy
away from formail -ns.

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