Re: How to change the unix-user's password from window.
Posted in 2000
Francisco: You can start here: http://expect.nist.gov/ Expect is a very useful utility. Here a sample: [snip] #!/usr/local/bin/expect -f # wrapper to make passwd(1) be non-interactive # username is passed as 1st arg, passwd as 2nd set oldpassword [lindex $argv 1] set newpassword [lindex $argv 2] spawn /usr/bin/passwd [lindex $argv 0] expect { "too short" {exit 10} "must contain" {exit 11} "must differ by" {exit 12} -re "failures|wrong passwd|Permission denied|does not exist" {exit 9} -ex "Enter login(NIS) password:" {send "$oldpassword\\r"; exp_continue} -ex "Enter login password:" {send "$newpassword\\r"; exp_continue} -ex "New password:" {send "$newpassword\\r"; exp_continue} -ex "Re-enter new password:" {send "$newpassword\\r"; exp_continue} timeout {exit 20} } [snip] BTW, I am running under Solaris 2.6. Steve Romankiw ----- Original Message ----- From: "Francisco Huezo" <fhuezo@mh.gob.sv> To: "Steve Romankiw" <sromankiw@execrisk.com>; <informix-list@iiug.org> Sent: Tuesday, September 12, 2000 3:36 PM Subject: Re: How to change the unix-user's password from window. > Thanks Steve. > > I tryed to use a similar script, like those > > echo "oldpasswd > newpasswd > newpasswd > " | passwd > > or > > passwd <<! > oldpasswd > newpaswd > newpassd > ! > > I also thought to use "system" call, but, netheir of them works. > Is "Expect" a software what you bought ? > > > El Tue, 12 Sep 2000, Steve Romankiw escribi': > > Francisco: > > > > We solved this problem by using stored procedures. Our Windows applications > > envokes the stored procedure via "execute procedure". The stored procedure > > contains a "system" call to a shell script. With the shell script, we are > > able to pass non-interactive information to UNIX's passwd utility. This is > > accomplished by using "expect". I cannot remember where I got "expect" > > from? > > > > HTH > > > > Steve Romankiw > > > > ----- Original Message ----- > > From: "Francisco Huezo" <fhuezo@mh.gob.sv> > > To: <informix-list@iiug.org> > > Sent: Monday, September 11, 2000 4:19 PM > > Subject: How to change the unix-user's password from window. > > > > > > > Hi list. > > > > > > My problem is that I want to change the password of user's account on Unix > > from > > > window. > > > > > > Of course, I can do it openning a telnet session and running passwd, but I > > want > > > to make a window where I can ask to user for his old and new password, > > > somewhat will be frendlier than simple telnet session. > > > > > > I'm going to appreciate a lot whatever advice. > > > -- > > > Francisco Huezo > > > Administrador de Base de Datos > > > Ministerio de Hacienda > > > Proyecto SAFI > > > Cond. Tres Torres, T-2, N-8 > > > San Salvador, El Salvador > > > Tel. (503) 225-3700 ext 102 > > > ------------------------------------------------- > > > > -- > Francisco Huezo > Administrador de Base de Datos > Ministerio de Hacienda > Proyecto SAFI > Cond. Tres Torres, T-2, N-8 > San Salvador, El Salvador > Tel. (503) 225-3700 ext 102 > ------------------------------------------------- >