From owner-freebsd-questions Wed Jul 18 17:55:50 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-27-141-144.mmcable.com [24.27.141.144]) by hub.freebsd.org (Postfix) with SMTP id BB20137B406 for ; Wed, 18 Jul 2001 17:55:46 -0700 (PDT) (envelope-from mwm@mired.org) Received: (qmail 19156 invoked by uid 100); 19 Jul 2001 00:55:46 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15190.12306.39284.169499@guru.mired.org> Date: Wed, 18 Jul 2001 19:55:46 -0500 To: BSD Freak Cc: questions@freebsd.org Subject: Re: Shell scripting gurus I nedd your help In-Reply-To: <107302904@toto.iv> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG BSD Freak types: > Here's one for the shell scripting gurus: > > I have a file (admins.txt) with list of the e-mail addresses of my > systems administrators (on per line) eg. > > john@ourcompnay.com > fred@ourcompany.com > betty@ourcompany.com > ... > ...etc > > > I need to be able to e-mail them all the same message from the command > line or a shell script (with only one command) > > For example I might need to email them the output of an "ls -al". I > could: > > ls -al | mail -s "Ouput of ls command" john@ourcompnay.com > ls -al | mail -s "Ouput of ls command" fred@ourcompnay.com > ls -al | mail -s "Ouput of ls command" betty@ourcompnay.com > ... > .etc.. > > how can I do this with only one command taking each persons e-mail > address from the file admins.txt Well, you *could* do: ls -al | mail -s "Output of ls command" `cat admins.txt` but it would be wrong. Better would be to set up a mail alias on that machine so that you can do: ls -al | mail -s "Output of ls command" admins For the default FreeBSD MTA - sendmail - and presumably for postfix, you can do this by adding the line: admins: :include:/full/path/to/admins.txt to /etc/mail/aliases, and then running newaliases as root. If you're using a different MTA, check the docs for that MTA. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message