LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-30-2004, 02:34 PM   #1
cpope67
LQ Newbie
 
Registered: Oct 2004
Posts: 8

Rep: Reputation: 0
Question Shell Script For Password


I am working on a script to set/change passwords for users. The script prompts you for the username and then the password. They are stored in variables: $uname and $pword. The script then runs passwd $uname. The output is this:

passwd chris

new password:

What I need to know at this point is how to get the value of $pword to be the input for the new password.

Thanks,
Chris
 
Old 12-30-2004, 04:01 PM   #2
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
You'll want to look into expect... I'm not sure how to use it, but
Code:
man expect
should shed some light
 
Old 12-31-2004, 06:05 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I'm not sure what you want to do. Why don't users simply use the passwd program?
 
Old 12-31-2004, 06:41 PM   #4
cpope67
LQ Newbie
 
Registered: Oct 2004
Posts: 8

Original Poster
Rep: Reputation: 0
Because there is about 6 different places they would have do do it, I am working on a script that will take that password and pass it and change it in other places to keep them syncronized so the users just have to keep up with one password.
 
Old 01-10-2005, 02:16 AM   #5
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You might consider using ldap or nis+. I don't have the experience on installing or using them to give you a how-to however.
Another option is using 'cfengine'. This is often used to distribute changes to many machines.
Another option is to use ssh to securely send the password to the other machines.

About setting the password prompt to $pword, I think using a here document might work.
Code:
passwd $uname <<+
$pword
+
Some references to look at:
For using NIS
http://davidcoulson.net/writing/pcp/...inuxexpert.pdf

Using OpenLDAP:
http://www.yolinux.com/RH-LDAP/s1-ldap-redhattips.htm

Explaining HERE documents:
http://www.linux.com/guides/abs-guide/here-docs.shtml

There are probably how-to's in the tldp.org website.

Last edited by jschiwal; 01-10-2005 at 02:21 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to change password kamal_aitin Linux - General 6 07-25-2007 12:09 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Setting password for users in a shell script?? krishvij Linux - Newbie 3 03-10-2005 09:17 AM
Password Shell Script Solaris 9 cpope67 Solaris / OpenSolaris 1 12-30-2004 03:15 PM
how to assign password for a user in shell script mtest Programming 10 10-29-2003 06:52 AM


All times are GMT -5. The time now is 01:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration