From owner-freebsd-questions@FreeBSD.ORG Sat Feb 5 19:43:34 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33D6D106566C for ; Sat, 5 Feb 2011 19:43:34 +0000 (UTC) (envelope-from peter@vfemail.net) Received: from vfemail.net (dotsevenfive.vfemail.net [69.11.239.75]) by mx1.freebsd.org (Postfix) with ESMTP id BDBF28FC12 for ; Sat, 5 Feb 2011 19:43:33 +0000 (UTC) Received: (qmail 51459 invoked by uid 89); 5 Feb 2011 19:43:26 -0000 Received: from localhost (HELO freequeue.vfemail.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2011 19:43:26 -0000 Received: (qmail 51432 invoked by uid 89); 5 Feb 2011 19:43:08 -0000 Received: from unknown (HELO www-51-2.vfemail.net) (vfemail@172.16.100.51) by FreeQueue with SMTP; 5 Feb 2011 19:43:08 -0000 Received: (qmail 39124 invoked by uid 89); 5 Feb 2011 19:43:16 -0000 Received: by simscan 1.4.0 ppid: 39106, pid: 39121, t: 0.2898s scanners:none Received: from unknown (HELO Bacchus.vfemail.net) (cGV0ZXJAdmZlbWFpbC5uZXQ=@67.101.12.44) by 172.16.100.51 with ESMTPA; 5 Feb 2011 19:43:15 -0000 X-Mailer: QUALCOMM Windows Eudora Version 7.1.0.9 Date: Sat, 05 Feb 2011 14:42:47 -0500 To: freebsd-questions@freebsd.org From: peter@vfemail.net Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Message-Id: <20110205194334.33D6D106566C@hub.freebsd.org> Subject: Trying to Make an Alias Execute a Perl Script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Feb 2011 19:43:34 -0000 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!