LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   BASH 1 script (https://www.linuxquestions.org/questions/linux-newbie-8/bash-1-script-385487/)

johnnyoi 11-22-2005 08:41 AM

BASH 1 script
 
hi all, does anyone know how to write a bash1 script that creates users, based on info from configuration files?

Or a link to a site with such information would be great.

Thank you,

John

prabuayyappan 11-22-2005 09:04 AM

which configuration file you mean.

johnnyoi 11-22-2005 10:00 AM

just a plain text file that has usernames, passwords, and password policies.

prabuayyappan 11-22-2005 11:10 AM

here is a sample script
----------------user.conf -----------------
name:user1
passwd:user11
name:user2
passwd:user22

---------------------------useradd.sh-----------
#!/bin/bash
i=0
while read line
do
array[$i]=`echo $line | awk -F ":" '{print $2}'`
let i=$i+1
done < user.conf
for j in `seq 0 2 $(($i-1))`
do
/usr/sbin/useradd ${array[$j]} -p ${array[$(($j+1))]}
done


All times are GMT -5. The time now is 01:49 PM.