Results 1 to 3 of 3
hi.
i have a small bash script who read for example a file .txt with user name and make the user and set even a password.
Code:
#!/bin/sh
for i ...
- 03-06-2008 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 10
create user script from file
hi.
i have a small bash script who read for example a file .txt with user name and make the user and set even a password.
the problem is that now for each user i must set a diferent UID and group.I will have direfernt files for example :Code:#!/bin/sh for i in `more userlist.txt ` do echo $i echo $i”123″ | passwd –stdin “$i” echo; echo “User $username’s password changed!” done
user.txt UID.txt group.txt
the file format is like this :
user1
user2
....
Thank you for help.
- 03-08-2008 #2Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
You'll need to create the user (useradd) before you can set the password, and by default Linux will give each user a different uid and gid anyway. If you really want to specify the uid and gid, you'd be better having a single file with the three values for each user on a line (eg "user1 501 500"), then you can read the file line by line in a while loop and do what you have to really easily.
- 03-08-2008 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 10
i will try it
thx


Reply With Quote