script to change password for all users

We have a server where we have a number of user ids and we also have the list of old passwords in a CSV file.
Now we want to change the password of all the users and assign them a default password.Can we write a shell script to do that.
I am planning to read the user name and corresponding password from CSV file.But how to login to the server with the same user and change password
with passwd -r file command.
Once i type login the exported paramter values are lost.

Any suggestion or sample script will help.

thanks
Deepak

with the --stdin option of the command 'passwd',you can do it easily as root

echo 'the old pass you read from csv file' | passwd --stdin user

post a sample of your csv file,i 'll try

user_id,old_password,new_password
dkrout,P@55word,dk@11word
sdas,P@55word,sd@12word
bkpradhan,P@55word,bk@19word
pthn,P@55word,pt@11word
nsap,P@55word,ns@11word

This is a sample CSV file I am having.I want to change the password to new password.I want to make everythin automated so that after the script run is complete password should change for all users and automated mail will be sent to them.

---------- Post updated at 07:44 PM ---------- Previous update was at 07:17 PM ----------

one thing i forgot to mention..i am not the root user.I am an ordinary user who wants to change the password.It is same as loggin in to individaul user using their password and change it and send a mail.To avoid manual work i want to automate it.

sorry,i don't know how if you can't access root,i just tried 'sudo',didn't work
i guess its for the security,you need to be root to change others password 'in script'

can you frame the script assuming that i am the root user..
i will try to convenience SA team to implement it once the script is ready

awk -F, 'NR!=1{system("echo "$3"|passwd --stdin "$1)}' yourCSVfile

and..about the mail,if you changed their passwords,how do they login and check mail without know the new password?hehe

we can add another column and have the corresponding mail ids ... not unix mail...and use mailx -s .... that is quite possible...i dont understand the use of system here

---------- Post updated at 10:13 PM ---------- Previous update was at 10:09 PM ----------

this is not working in my system ....

---------- Post updated at 10:26 PM ---------- Previous update was at 10:13 PM ----------

won't this ask for old password and confirmation password if i am running it from root..as i dont have that access its not working .....
will it work in Sun Solaris too ??

yes,it won't ask anything,is that what you looking for?automatically :slight_smile:
i use linux,never had a chance to use solaris,so...you give a try