The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 06-05-2008
upengan78 upengan78 is offline
Registered User
  
 

Join Date: Jun 2008
Location: Texas
Posts: 142
I found it myself

Quote:
#!/bin/ksh

ChangePasswd()
{
/usr/local/bin/expect <<EOF
spawn passwd $user
expect "New Password: "
send -- "$2\r"
expect "Re-enter new Password: "
send -- "$2\r"
expect eof
EOF
}
#while read -p "Enter Userid:" user
while read user
do
if [[ $user != '' ]];
then
ChangePasswd $user $1
fi
done <ab
## ab file has the list of users whose password I am changing

I run the above script as ./script <password I want>

that sets the password for all users to what I want !