[ubuntu-my] simple bash scripting question

Muhd Syazwan Md Khusaini jipang_menjerit at ubuntuseekers.com
Mon May 3 18:43:04 BST 2010


wah..topic ni pun aku dah pening..
tapi menarik..

so, is those line settle up your miserable coded life?

On Mon, May 3, 2010 at 12:41 PM, Umarzuki Mochlis <umarzuki at gmail.com>wrote:

>
> create users according to folders in /home
>> change ownership of each user to their own
>>
>
> here is my code for the last 2 lines (others can be done manually with tar
> and ssh)
> #!/bin/bash
> ## This for loop create a file with username and passwordformat
> ## needed by chpasswd
> for i in /home/*
> do
>         user=$(echo $i | awk -F/ '{ print $3 }')
>         echo $user:zaq12wsx >> userpass.txt
> done
>
> ## This for loop creates a user, sets its predefined password
> ## which is zaq12wsx
> for i in /home/*
> do
>         user=$(echo $i | awk -F/ '{ print $3 }')
>         echo $user
>         useradd $user; chown -R $user:$user $i; chpasswd < userpass.txt
> done
> ## code end
>
> and of course i'll save my behind by attaching a BSD license to this code
>
> comments?
>
> --
> Regards,
>
> Umarzuki Mochlis
> http://debmal.my
>
> --
> Ubuntu-my mailing list
> Ubuntu-my at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-my
>
>


-- 
Muhd Syazwan @ jipang_menjerit
blog.ubuntuseekers.com
jipang_menjerit at ubuntuseekers.com

One Online Radio
www.oneonline.cjb.net
me at oneonline.cjb.net

Join Ubuntu Manual Project!
http://wiki.ubuntu.com/ubuntu-manual
https://www.launchpad.net/ubuntu-manual
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/ubuntu-my/attachments/20100504/739d476e/attachment.htm 


More information about the Ubuntu-my mailing list