From owner-freebsd-questions Wed Jul 18 19:55:22 2001 Delivered-To: freebsd-questions@freebsd.org Received: from lcmail2.lc.ca.gov (lcmail2.lc.ca.gov [165.107.12.11]) by hub.freebsd.org (Postfix) with ESMTP id 0E29337B403 for ; Wed, 18 Jul 2001 19:55:18 -0700 (PDT) (envelope-from drewt@writeme.com) Received: from CONVERSION-DAEMON by lcmail2.lc.ca.gov (PMDF V5.2-27 #40821) id <0GGP00N019GVNF@lcmail2.lc.ca.gov> for questions@freebsd.org; Wed, 18 Jul 2001 19:55:44 -0700 (PDT) Received: from tagalong ([165.66.11.101]) by lcmail2.lc.ca.gov (PMDF V5.2-27 #40821) with SMTP id <0GGP00E7C9GURY@lcmail2.lc.ca.gov> for questions@freebsd.org; Wed, 18 Jul 2001 19:55:43 -0700 (PDT) Date: Wed, 18 Jul 2001 19:55:07 -0700 From: Drew Tomlinson Subject: RE: Shell scripting gurus I nedd your help In-reply-to: <15190.12306.39284.169499@guru.mired.org> To: 'Mike Meyer' , BSD Freak Cc: questions@freebsd.org Message-id: <5CD46247635BD511B6B100A0CC3F0239259FFB@ldcmsx01.lc.ca.gov> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal 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 > -----Original Message----- > From: Mike Meyer [mailto:mwm@mired.org] > Sent: Wednesday, July 18, 2001 5:56 PM > To: BSD Freak > Cc: questions@freebsd.org > Subject: Re: Shell scripting gurus I nedd your help > > > 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. I just happen to be taking an intro UNIX class this week and learned about this today. I'm just curious why this would be wrong. Is it inefficient? Why is the alias better? I'm just trying to understand all of this. :) Thanks, Drew > 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. > > -- > Mike Meyer 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message