Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jul 2001 19:55:07 -0700
From:      Drew Tomlinson <drewt@writeme.com>
To:        'Mike Meyer' <mwm@mired.org>, BSD Freak <bsd-freak@mbox.com.au>
Cc:        questions@freebsd.org
Subject:   RE: Shell scripting gurus I nedd your help
Message-ID:  <5CD46247635BD511B6B100A0CC3F0239259FFB@ldcmsx01.lc.ca.gov>
In-Reply-To: <15190.12306.39284.169499@guru.mired.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> -----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 <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.

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
> --
> 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


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?5CD46247635BD511B6B100A0CC3F0239259FFB>