Dushan Silva
asked on
Auto User Creating Linux Script
Hi Experts,
I want Linux Script with following specifications.
*Create Linux users.
usernames, passwords, home directories are in a seperate CSV (comma seperated file)configuration file. When I run the script, automatically users should created acording to the configuration file.
Configuration file will looks as follows:
-------------------------- ---------- ---------- --
user1, password1, homedir1
user2, password2, homedir2
user3, password3, homedir3
-------------------------- ---------- ---------- ---
(And if possible when I enter only the user name, password should automatically sets to the reverse word of the username , eg: 1resu)
And if users are already exist, then no need to create it again and after the script is over output(mentioning whether users have created or not) errors/details should write to a log file.
I would greatly appreciate your help.
Best Regards,
Dushan
I want Linux Script with following specifications.
*Create Linux users.
usernames, passwords, home directories are in a seperate CSV (comma seperated file)configuration file. When I run the script, automatically users should created acording to the configuration file.
Configuration file will looks as follows:
--------------------------
user1, password1, homedir1
user2, password2, homedir2
user3, password3, homedir3
--------------------------
(And if possible when I enter only the user name, password should automatically sets to the reverse word of the username , eg: 1resu)
And if users are already exist, then no need to create it again and after the script is over output(mentioning whether users have created or not) errors/details should write to a log file.
I would greatly appreciate your help.
Best Regards,
Dushan
There is a perl script here http://www.dfw.net/~scottvr/batchadd.pl, but it is without the homedir part. It can be modified quite fast.
ASKER
Hi All,
Thanks for your input!
But I want Linux Shell script, not a perl script. :)
yuzh >>
I would greatly appreciate, if you could put shell script , since I'm less familiar with "expect" command. Could you bit eloborate it.
BR Dushan
Thanks for your input!
But I want Linux Shell script, not a perl script. :)
yuzh >>
I would greatly appreciate, if you could put shell script , since I'm less familiar with "expect" command. Could you bit eloborate it.
BR Dushan
>>I would greatly appreciate, if you could put shell script , since I'm less familiar with "expect" command. Could you bit eloborate it.
1) You need to have "expect" installed on your system:
http://expect.nist.gov/
serach the web to see if there is a binary package for your OS version.
2) do a "man useradd" on your system to see what options you can use
eg:
useradd -c "User comment or GCOS" -d /home/newuser -p passwd -g group -m -k /etc/skel -s bin/sh newuser
write down what options you want to use, then run autoexpect to create an expect script on your system.
We can help you to modify the script to accept the loginname password home-dir
(+ default login shell if you wish) as the commandline. then put all of them together to make the script.
autoexpect is very easy to use, do a "man autoexpect" to learn more details.
also have a look at
http:Q_11245534.html
to learn how to handle the password for "useradd -p"
or
simplely use expect script to set the password (passwd loginname).
1) You need to have "expect" installed on your system:
http://expect.nist.gov/
serach the web to see if there is a binary package for your OS version.
2) do a "man useradd" on your system to see what options you can use
eg:
useradd -c "User comment or GCOS" -d /home/newuser -p passwd -g group -m -k /etc/skel -s bin/sh newuser
write down what options you want to use, then run autoexpect to create an expect script on your system.
We can help you to modify the script to accept the loginname password home-dir
(+ default login shell if you wish) as the commandline. then put all of them together to make the script.
autoexpect is very easy to use, do a "man autoexpect" to learn more details.
also have a look at
http:Q_11245534.html
to learn how to handle the password for "useradd -p"
or
simplely use expect script to set the password (passwd loginname).
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
script or "perl" to handle the password.
Please read the answers in:
http:Q_21112403.html
http:Q_20339413.html
http:Q_21158545.html
to learn more details.