Scripting Mass creation of accounts w/ randomized passwords

Warren Togami warren at togami.com
Tue Jan 29 03:11:18 PST 2002


#!/bin/sh

rm -f GENLIST
rm -f ACCTLIST
rm -f UNDOGENLIST

for u in `cat NAMES`; do
    rm -f temppass.txt
    cat /dev/urandom | tr -dc '[a-zA-Z0-9]' | tr -d '[' | tr -d ']' | dd
of=temp
pass.txt bs=8 count=1 > /dev/null
    echo Name: $u     Password: $(cat temppass.txt) >> ACCTLIST
    echo useradd $u -s /usr/bin/passwd >> GENLIST
    echo "echo $(cat temppass.txt) | passwd $u --stdin" >> GENLIST
    echo userdel -r $u >> UNDOGENLIST
done

Anyone have a clue how I can add error checking to this script?  I think the
only error condition it must check for is accounts that already exist.  Any
other potential problems here?



More information about the LUAU mailing list