[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sendmail questions
Quoth Geoffrey S. Mendelson on Mon, Aug 16, 1999:
> erez@savan.com wrote:
> > 3. can i make a mail alias which takes a list and removes some
> > ( e.g. all: avi,dani,yossi,efraim
> > >> all-: all execpt avi <<
To exclude a user, use 'grep -v'.
> > )
>
> Any easy way to create the file would be
>
> cat /etc/passwd | awk -F: '($2 > 100) {print $1}' >/etc/allusers
^^
$3, actually. And the parentheses are not needed, although they
do make the line look nicer.
> This will ignore root, bin, etc.
It won't usually ignore nobody and nonroot, though. Maybe you
want to change the awk one-liner to:
awk -F: '$3 > 100 && $3 < 32767 {print $1}'
On systems where both nobody and nonroot exist, nobody's UID is
usually 32767, and nonroot's is 65534. But your mileage (or
kilometrage, if you're not American) may wary. On some Linux
systems, for example, nobody is 99, nonroot doesn't exist, and
postgres is 100, while on some systems 100 is the default UID of
the first user added by the adduser script.
And one more thing: there was a discussion here about 'cat
/etc/passwd' vs. '</etc/passwd' redirection. Actually, to save a
process and avoid the danger of redirecting to /etc/passwd, you
may just give the file name as an additional parameter to awk, as
in:
awk -F: '$3 > 100 && $3 < 32767 {print $1}' /etc/passwd >/etc/allusers
This works with both GNU awk and the awk which comes with SunOS
4.1.4, so it's probably a standard feature (unfortunately, I
haven't got the nice 4.3BSD manual set here).
Although in most setups it's irrelevant, as what you really want
to pipe into awk is the output of "ypcat passwd" or something
similar.
Time to sleep!
Vadik.
--
The ill-formed Orange
Fails to satisfy the eye:
Segmentation fault.
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il