Change Password In A Shell Script

Reply

Join Date: May 2005
Posts: 1
Reputation: captor is an unknown quantity at this point 
Solved Threads: 0
captor captor is offline Offline
Newbie Poster

Change Password In A Shell Script

 
0
  #1
Apr 12th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 468
Reputation: TKS will become famous soon enough TKS will become famous soon enough 
Solved Threads: 17
TKS's Avatar
TKS TKS is offline Offline
Posting Pro in Training

Re: Change Password In A Shell Script

 
0
  #2
Apr 19th, 2006
You shouldn't have to do it. Linux has this built in with

passwd
My Home Away from Home: Yet Another Linux Blog
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: Change Password In A Shell Script

 
0
  #3
May 9th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 177
Reputation: jim mcnamara is on a distinguished road 
Solved Threads: 10
jim mcnamara jim mcnamara is offline Offline
Junior Poster

Re: Change Password In A Shell Script

 
0
  #4
May 12th, 2006
Sounds like a class asignment.
try a here document
Shell Scripting Syntax (Toggle Plain Text)
  1. oldpw="$1"
  2. newpw="$2"
  3. passwd <<EOF
  4. "$1"
  5. "$2"
  6. "$2"
  7. EOF
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1
Reputation: webtrekker is an unknown quantity at this point 
Solved Threads: 0
webtrekker webtrekker is offline Offline
Newbie Poster

Re: Change Password In A Shell Script

 
0
  #5
May 31st, 2006
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
Last edited by 'Stein; Aug 14th, 2006 at 2:32 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: Change Password In A Shell Script

 
0
  #6
Jun 1st, 2006
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
Attached Files
File Type: txt ChangePassword.exp.txt (2.7 KB, 667 views)
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 1
Reputation: vivekp is an unknown quantity at this point 
Solved Threads: 0
vivekp vivekp is offline Offline
Newbie Poster

Re: Change Password In A Shell Script

 
0
  #7
Jun 21st, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1
Reputation: ezradibiase is an unknown quantity at this point 
Solved Threads: 0
ezradibiase's Avatar
ezradibiase ezradibiase is offline Offline
Newbie Poster

Re: Change Password In A Shell Script

 
0
  #8
Jul 7th, 2006
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

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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 1
Reputation: VinodKumar is an unknown quantity at this point 
Solved Threads: 0
VinodKumar VinodKumar is offline Offline
Newbie Poster

Re: Change Password In A Shell Script

 
0
  #9
Aug 14th, 2006
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
Last edited by 'Stein; Aug 14th, 2006 at 2:33 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 30
Reputation: sut is an unknown quantity at this point 
Solved Threads: 1
sut sut is offline Offline
Light Poster

Re: Change Password In A Shell Script

 
0
  #10
Sep 6th, 2006
Originally Posted by kamitsin View Post
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: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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC