| | |
Change Password In A Shell Script
![]() |
•
•
Join Date: May 2005
Posts: 1
Reputation:
Solved Threads: 0
Hi All,
I have a problem.
I need to write a shell script to change the password. The user may want to change his own password by this script.
He will have to provide the required 3 parameters i.e. old password, new password and retype new password as arguments in command line.
like, ./pass.sh old new new
How do I do it. I am in a fix.
I am not allowed to use expect etc.
Please help me.
Thanks.
Asimananda
I have a problem.
I need to write a shell script to change the password. The user may want to change his own password by this script.
He will have to provide the required 3 parameters i.e. old password, new password and retype new password as arguments in command line.
like, ./pass.sh old new new
How do I do it. I am in a fix.

I am not allowed to use expect etc.
Please help me.
Thanks.
Asimananda
You shouldn't have to do it. Linux has this built in with
passwd
passwd
My Home Away from Home: Yet Another Linux Blog
•
•
Join Date: Apr 2006
Posts: 16
Reputation:
Solved Threads: 0
i am using a shell script which changes the password of all the servers in the network and also of the host server (as per your requirement) but it uses except.
Earlier i had a perl script to change the password.
If you want i can give you both the scripts and you can modify them as per your requirement.
Amit
Earlier i had a perl script to change the password.
If you want i can give you both the scripts and you can modify them as per your requirement.
Amit
•
•
Join Date: May 2004
Posts: 178
Reputation:
Solved Threads: 10
Sounds like a class asignment.
try a here document
try a here document
Shell Scripting Syntax (Toggle Plain Text)
oldpw="$1" newpw="$2" passwd <<EOF "$1" "$2" "$2" EOF
•
•
Join Date: May 2006
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by kamitsin
i am using a shell script which changes the password of all the servers in the network and also of the host server (as per your requirement) but it uses except.
Earlier i had a perl script to change the password.
If you want i can give you both the scripts and you can modify them as per your requirement.
Amit
I would be very interested in your scripts. Would you mind sending them to me at . This sounds exactly what I am needing.
Thanks
PS
Last edited by 'Stein; Aug 14th, 2006 at 2:32 am.
•
•
Join Date: Apr 2006
Posts: 16
Reputation:
Solved Threads: 0
I have attached the modified script beacuse the original script is for changing the password across multiple servers and i guess this is not what you require.
You need to execute the script from root user. It will create a log file in the directory from which you are executing the script.
You can change the password for root and a user but you can do a small modification and the script will change the password for root and any user.
Amit
You need to execute the script from root user. It will create a log file in the directory from which you are executing the script.
You can change the password for root and a user but you can do a small modification and the script will change the password for root and any user.
Amit
•
•
Join Date: Jun 2006
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by kamitsin
I have attached the modified script beacuse the original script is for changing the password across multiple servers and i guess this is not what you require.
You need to execute the script from root user. It will create a log file in the directory from which you are executing the script.
You can change the password for root and a user but you can do a small modification and the script will change the password for root and any user.
Amit
Hi Amit,
Do you have a similar script (only ChangePasswd) in Perl? If you do can you please share it.
Thanks,
Vivek.
Hi Amit,
I am looking for a script just like yours: I have many servers and I need to change their root psw.
Could you post the entire script?
thanks a lot
Ezra
I am looking for a script just like yours: I have many servers and I need to change their root psw.
Could you post the entire script?
thanks a lot
Ezra
•
•
•
•
Originally Posted by kamitsin
I have attached the modified script beacuse the original script is for changing the password across multiple servers and i guess this is not what you require.
You need to execute the script from root user. It will create a log file in the directory from which you are executing the script.
You can change the password for root and a user but you can do a small modification and the script will change the password for root and any user.
Amit
•
•
Join Date: Aug 2006
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by kamitsin
I have attached the modified script beacuse the original script is for changing the password across multiple servers and i guess this is not what you require.
You need to execute the script from root user. It will create a log file in the directory from which you are executing the script.
You can change the password for root and a user but you can do a small modification and the script will change the password for root and any user.
Amit
Im looking for the script which you have for changing password on multiple servers. Would you mind sending them to me at.
Thanks and regards,
VinodKumar
Last edited by 'Stein; Aug 14th, 2006 at 2:33 am.
•
•
Join Date: Sep 2006
Posts: 30
Reputation:
Solved Threads: 1
•
•
•
•
I have attached the modified script beacuse the original script is for changing the password across multiple servers and i guess this is not what you require.
You need to execute the script from root user. It will create a log file in the directory from which you are executing the script.
You can change the password for root and a user but you can do a small modification and the script will change the password for root and any user.
Amit
I am trying to get a perl script to communicate with the passwd program. I do not have access to the modules expect or IO:
ty. I also do not have access to the expect utility.So far I have found a free pty/tty pair and opened them and set them to autoflush. Then I fork.
In the child I close stdin, stdout and stderr to reopen them associated to the new tty handle and exec passwd.
In the parent I want to read and write to the pty to interact with passwd. This is not working. The passwd direct access to the tty is not reaching my tty.
Maybe I need to set the controling tty in the child before doing the exec? How do I do that?
Cheers,
sut
![]() |
Other Threads in the Shell Scripting Forum
- Previous Thread: Absolut Newbie
- Next Thread: Clicking Yes on Window
| Thread Tools | Search this Thread |





