in shell script

February 26, 2009 at 04:42:34
Specs: Unix, 512 GB
hi i am working in shell script i want to write shell script program to create new user.suppose if the user name is already exist then i should change the password automatically can u help me

See More: in shell script

Report •

February 27, 2009 at 02:23:05
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
echo "Only root may add a user to the system"
exit 2

i tried this one for new user but i wnt to change the old user password also.

Report •
Related Solutions

Ask Question