DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Shell Scripting (http://www.daniweb.com/forums/forum113.html)
-   -   Change Password In A Shell Script (http://www.daniweb.com/forums/thread43195.html)

captor Apr 12th, 2006 1:49 am
Change Password In A Shell Script
 
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

TKS Apr 19th, 2006 3:34 pm
Re: Change Password In A Shell Script
 
You shouldn't have to do it. Linux has this built in with

passwd

kamitsin May 9th, 2006 10:28 am
Re: Change Password In A Shell Script
 
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

jim mcnamara May 12th, 2006 3:15 pm
Re: Change Password In A Shell Script
 
Sounds like a class asignment.
try a here document
oldpw="$1"
newpw="$2"
passwd <<EOF
"$1"
"$2"
"$2"
EOF

webtrekker May 31st, 2006 2:22 pm
Re: Change Password In A Shell Script
 
Quote:

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

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

kamitsin Jun 1st, 2006 10:01 am
Re: Change Password In A Shell Script
 
1 Attachment(s)
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

vivekp Jun 21st, 2006 12:25 pm
Re: Change Password In A Shell Script
 
Quote:

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.

ezradibiase Jul 7th, 2006 10:21 am
Re: Change Password In A Shell Script
 
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

Quote:

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


VinodKumar Aug 14th, 2006 12:12 am
Re: Change Password In A Shell Script
 
Quote:

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,

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

sut Sep 6th, 2006 12:52 pm
Re: Change Password In A Shell Script
 
Quote:

Originally Posted by kamitsin (Post 221061)
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

Hello 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::Pty. 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


All times are GMT -4. The time now is 12:37 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC