Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Apr 1998 21:38:05 -0400
From:      "Troy Settle" <rewt@i-Plus.net>
To:        "Dave Chapeskie" <dchapes@ddm.on.ca>
Cc:        <freebsd-isp@FreeBSD.ORG>
Subject:   Re: passwd to .htpasswd script
Message-ID:  <015a01bd64ea$79d048a0$3a4318d0@abyss.b.nu>

next in thread | raw e-mail | index | archive | help
Dave:

I appreciate the feedback.  I've only been working out on shell utilities
for a while now, and am still quite green.

However, I think that it should be noted that there is (almost) always
more than one way to do things.  I came up with a solution that worked,
ignore the fact that your's is far more efficient.

For doing what needs to be done, I would have used a perl script,
however, Susie (the person who asked for my help), didn't want to mess
with it that way.  In a hurry, I came up with the script I posted.

It's good that you've posted a more efficient method, but the tone of
your post was quite rude.  Perhaps it would have been better to start it
out with "Yeah, that works, but this is more efficient:"

--
    Troy Settle <st@i-Plus.net>
    Network Administrator, iPlus Internet Services
    http://www.i-Plus.net



-----Original Message-----
From: Dave Chapeskie <dchapes@ddm.on.ca>
To: Troy Settle <rewt@i-Plus.net>
Cc: freebsd-isp@FreeBSD.ORG <freebsd-isp@FreeBSD.ORG>
Date: Friday, April 10, 1998 8:21 PM
Subject: Re: passwd to .htpasswd script


>On Fri, Apr 10, 1998 at 09:27:07AM -0400, Troy Settle wrote:
>> #!/bin/sh
>> count=`/usr/bin/wc -l /etc/master.passwd | awk '{ print $1}'`
>> numusers=`/bin/expr ${count} - 14`
>> /usr/bin/tail -n ${numusers} /etc/master.passwd | /usr/bin/cut -f
1,2 -d :
>
>This is VERY inefficient.  It involves two passes over the file one of
>which needs to buffer almost the whole file!  Also it makes assumptions
>about the number of system accounts, if you add a new system account
>(majordomo, postgres, etc) you have to find and change your script.  A
>MUCH better solution would be:
>
>awk -F: '$3 >= 1000 {print $1 ":" $2}' /etc/master.passwd
>
>One command, one pass, one assumption.
>
>You replace 1000 with the starting UID of real users (as opposed to
>system accounts).  Any smart sysadmin keeps all system account UIDs
>bellow a certain value so this is not as bad of an assumption.
>
>(BTW, if you want this one command as a script use something like:
>    #!/bin/sh
>    exec awk -F: '$3 >= 1000 {print $1 ":" $2}' /etc/master.passwd
>I dislike it when people forget the exec.)
>
>
>Please refrain from posting scripts or answers to the mailing lists
>unless you know what you are doing.  (Not to single you out, but
>I've seen a lot of very poor or wrong answers posted to lists and it
>annoys me sometimes).  IMHO bad answers/examples are worse than no
>answers/examples.
>
>--
>Dave Chapeskie, DDM Consulting
>E-Mail: dchapes@ddm.on.ca
>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?015a01bd64ea$79d048a0$3a4318d0>