John Conover <john(_at_)johncon(_dot_)johncon(_dot_)com> writes:
HylFax is a fax server that has sources available via anonymous ftp to
sgi.com. To distribute faxes received by HylaFax into the Unix mail
system, using procmail as the interface, put the following in the
FaxMaster's ~/.procmailrc:
:0:
* ^from:(_dot_)*fax(_at_)my_domaincom
{
:0 c
* ^subject: +facsimile +received +from
| ${HOME}/.faxmail
:0:
fax
}
which will invoke the shell script file, named ~/.faxmail, and parse
the received fax file name from the fax notification email sent by
HylaFax, and route a MIME copy of the fax to the specified email
address using the metasend program from the MIME distribution:
#!/bin/sh
FILE_NAME=`egrep ^recvq | sed 's/:.*$//' | sed 's/^/\/usr\/spool\/uucppubl
ic\/fax\//'`
/usr/local/bin/metasend -b -t someone(_at_)my_domain(_dot_)com -F
fax(_at_)my_domain(_dot_)com -s "Facsimile mail transmission" -m
application/fax -f `echo ${FILE_NAME}`
(Note that someone wishing to demonstrate some competency with sed(1)
could eliminate one of the sed invocations.)
Why use sed at all? The following does it all in procmail:
# You don't need a local lock on a compound action
:0
* ^From:(_dot_)*fax(_at_)my_domain\(_dot_)com
{
:0 c
* ^Subject: +facsimile +received +from
* B ?? ^\/recvq[^:]*
|/usr/local/bin/metasend -b -t someone(_at_)my_domain(_dot_)com -F
fax(_at_)my_domain(_dot_)com \
-s "Facsimile mail transmission" -m application/fax \
-f "/usr/spool/uucppublic/$MATCH"
:0:
fax
}
However, I don't think you really mean to parse out the filename in the
way you currently are. What does the 'recvq' line of the incoming message
actually look like? Right now you're using everything from the begining
of the line (including the 'recvq') to the first colon (not including the
colon itself) as the filename. I'm guessing that you really want to use
everything _after_ the colon, in which case the above recipe should contain:
* B ?? ^recvq[^:]*: *\/.*
Or in your .faxmail script:
#!/bin/sh
FILE_NAME=`sed -n '/^recvq/s/^[^:]*: *//p'`
/usr/local/bin/metasend -b -t someone(_at_)my_domain(_dot_)com -F
fax(_at_)my_domain(_dot_)com \
-s "Facsimile mail transmission" -m application/fax \
-f "/usr/spool/uucppublic/$FILE_NAME"
Note that running echo in backquotes is (almost) a null operation.
Philip Guenther
----------------------------------------------------------------
Philip Guenther UNIX Systems and Network Administrator
Internet: guenther(_at_)gac(_dot_)edu Phonenet: (507) 933-7596
Gustavus Adolphus College St. Peter, MN 56082-1498
Source code never lies (it just misleads). (Programming by Purloined Letter?)