LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Shell Script For Password (https://www.linuxquestions.org/questions/programming-9/shell-script-for-password-271997/)

cpope67 12-30-2004 02:34 PM

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

scuzzman 12-30-2004 04:01 PM

You'll want to look into expect... I'm not sure how to use it, but
Code:

man expect
should shed some light :D

jschiwal 12-31-2004 06:05 AM

I'm not sure what you want to do. Why don't users simply use the passwd program?

cpope67 12-31-2004 06:41 PM

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.

jschiwal 01-10-2005 02:16 AM

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.


All times are GMT -5. The time now is 07:25 AM.