2009/7/15 Ryan Ghering <[email protected]>:
> I need to convert 3200 Freebsd user accounts over to linux passwd format has
> anyone done this?
> I REALLY don't want to add each user account one at a time.
>
> Shell script? Perl ?
It'd be pretty trivial with grep and awk. Here is an ugly script I
used to add users to a mail server from a flat text file.
#!/bin/bash
i=1
while [ "$i" != 2 ]
do
firstname=`cat -n fullusers.txt |grep $i |awk -F\ '{print
$2}'|head -n 1`
lastname=`cat -n fullusers.txt |grep $i |awk -F\ '{print
$3}'|head -n 1`
password=`/root/scripts/password.py`
echo rs-$firstname.$lastname
# echo $password
echo eMail\: [email protected] Password\:
$password>>userpass.txt
useradd -g users -d /home/rs-$firstname.$lastname -s
/bin/false -m rs-$firstname.$lastname
/root/scripts/chpasswd rs-$firstname.$lastname $password
echo $firstname.$lastname\: rs-$firstname.$lastname >>
/etc/exim/domain.com
let "i += 1"
done
--------------------------------------------------------------------------------
WISPA Wants You! Join today!
http://signup.wispa.org/
--------------------------------------------------------------------------------
WISPA Wireless List: [email protected]
Subscribe/Unsubscribe:
http://lists.wispa.org/mailman/listinfo/wireless
Archives: http://lists.wispa.org/pipermail/wireless/