Date: Wed, 18 Jul 2001 19:55:46 -0500 From: Mike Meyer <mwm@mired.org> To: BSD Freak <bsd-freak@mbox.com.au> Cc: questions@freebsd.org Subject: Re: Shell scripting gurus I nedd your help Message-ID: <15190.12306.39284.169499@guru.mired.org> In-Reply-To: <107302904@toto.iv>
next in thread | previous in thread | raw e-mail | index | archive | help
BSD Freak <bsd-freak@mbox.com.au> 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. <mike -- Mike Meyer <mwm@mired.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15190.12306.39284.169499>