>-----Original Message-----
>From: Chris G Haravata [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, July 12, 2001 8:05 PM
>To: PLUG Mailing List
>Subject: [plug] readiing a line from a file and putting that in a variable
>Importance: High
>
>anyway, the problem is this:  i need to create a script which will
automatically create user home directories from a file.  but i need to read
the file first from within the script.  the file looks like the ff:
 
/home/2000/abc-123455
/home/1995/def-678901
/home/2001/ghi-234567
<etc until 1125 lines later>
 
>problem is:  is there a command to use which will read each line of the
file and put the contents of that line >in a variable?  

Here is a short hack i created. have fun!!!!

assuming you have a file named /root/users and it contains something like
/home/user1
/home/user2
/home/user3
.
.
.
/home/user10000

and assuming also you have a group named staff.

create a file say autocreateusers and it will contain

#!/bin/sh
userctr=10000
for i in `cat /root/users | cut -f 3 -d/`;
do
   userctr=`expr $userctr + 1`;
   useradd -u $userctr -G staff -d /home/$i -s /bin/sh $i;
   mkdir /home/$i;
   chown $i.staff /home/$i;
done;

tapos, execute mo na siya by doing ./autocreateusers or sh -x
autocreateusers

your job now is to figure out how to set password your 10000 users. :->

I tried that script kanina and it's ok.

-onie
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to