[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: adding multiple users, newuser? and vim



on Sat, Aug 25, 2001 at 07:29:57PM -0600, Cameron Matheson (cmatheson3@yahoo.com) wrote:
> On 25 Aug 2001 18:19:53 -0700, Osamu Aoki wrote:
> 
> > Writing TEXT processing script in BASH is just a quick job.  For real
> > world needs, use AWK (See Karsten's answer to your post), PERL, or PYTHON.
> 
> Don't forget Ruby :)
> Sorry, but it's my favorite... i just need to start learning it better

;-)

Actuallly, I should be forcing myself to use Python, but habits die hard
and I just know my way around sed and awk pretty well, so they're the
first thing I turn to when a shell script stops being what I want.

I've actually updated my AWK script to something more full-featured.
Attached.

-- 
Karsten M. Self <kmself@ix.netcom.com>          http://kmself.home.netcom.com/
 What part of "Gestalt" don't you understand?             There is no K5 cabal
  http://gestalt-system.sourceforge.net/               http://www.kuro5hin.org
   Free Dmitry! Boycott Adobe! Repeal the DMCA!    http://www.freesklyarov.org
Geek for Hire                        http://kmself.home.netcom.com/resume.html
#!/usr/bin/awk -f

# Script to create a file suitable for use in the 'newusers' command,
# from a file consisting of user IDs and passwords in the form:
# First Last password
# Copyright (c) KMSelf Sat Aug 25 20:47:38 PDT 2001
# Distributed under GNU GPL v 2, or at your option, any later version.
# This program is distributed WITHOUT ANY WARRANTY.

BEGIN {
    # Assign starting UID, GID
    if ( ARGC > 2 ) {
	startuid = ARGV[1]
	delete ARGV[1]
    }
    else {
        printf( "Usage:  newusers <startUID> <file>\n" \
	  "...where startUID is the starting userid to add, and file is \n" \
	  "an input file in form <first name> <last name> <password>\n" \
	)

	exit
    }

    infile = ARGV[1]
    printf( "Starting UID: %s\n\n", startuid )
}

/^#/ { next }

{
    ++record
    first = $1
    last = $2
    passwd = $3
    user= substr( tolower( first ), 1, 1 ) tolower( last )
    uid = startuid + record - 1
    gid = uid
    printf( "%s:%s:%d:%d:%s %s,,/home/%s:/bin/bash\n",  \
	user, passwd, uid, gid, first, last, user \
	)
}

Attachment: pgpRifYJvEFUr.pgp
Description: PGP signature


Reply to: