Date: Sat, 05 Feb 2011 14:42:47 -0500 From: peter@vfemail.net To: freebsd-questions@freebsd.org Subject: Trying to Make an Alias Execute a Perl Script Message-ID: <20110205194334.33D6D106566C@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
I have a couple of entries in my /etc/mail/aliases that manipulate the contents of an e-mail message. For example, file: "| cat > /home/user/file.incoming" receives an e-mail message and writes it to the hard drive. Another example: format: "| sed 's/^.$/~~/g' | sed 's/^$/~~/g' | tr -s ' ' ' ' | fmt 63 64 | sed 's/^ *//g' | tr '~' '\\012\' | mail user" receives a message, reformats the contents, and sends the reformatted material back to me by e-mail. I'm trying to create a new alias that will receive an e-mail message, use a Perl command to scan for for all e-mail addresses, and return a list of any e-mail addresses found to me by e-mail. This little Perl command does a great job of identifying e-mail addresses and producing a list of them: perl -wne 'while(/[\S\.]+@[\S\.]+\w+/g){print "$&\n"}' and I can use this from the command line these ways to extract e-mail addresses from a file: perl -wne 'while(/[\S\.]+@[\S\.]+\w+/g){print "$&\n"}' datafile perl -wne 'while(/[\S\.]+@[\S\.]+\w+/g){print "$&\n"}' < datafile cat datafile | perl -wne 'while(/[\S\.]+@[\S\.]+\w+/g){print "$&\n"}' I've tried this entry in my /etc/mail/aliases file, but it returns an empty e-mail messages: extract: "| perl -wne 'while(/[\S\.]+@[\S\.]+\w+/g){print "$&\n"}' | mail user" I tried modifying it to create a datafile and then examine the datafile: extract: "| cat > datafile | perl -wne 'while(/[\S\.]+@[\S\.]+\w+/g){print "$&\n"}' < datafile | mail user" but it is still returning an empty e-mail message rather than a list of e-mail addresses. What am I overlooking? ------------------------------------------------- This message sent via VFEmail.net http://www.vfemail.net $14.95 Lifetime accounts! 15GB disk! No bandwidth quotas!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110205194334.33D6D106566C>