Expect Script to Change Password 
Author Message
 Expect Script to Change Password

hi all,

We are having some problem while trying to write some simple
password-changing expect script on a fresh installed RH5.0 machine.

Problem Description:
The script is simple.  It's intended to be run by user "nobody", with
three arguments: username, oldpassword and newpassword. So it will
first spawn a "su $user -c passwd" process, then it will supply old
password twice, new password twice.

But oddly enough, here is my debugging output:
=====
spawn su gwei -c /usr/bin/passwd
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {1698}

expect: does "" (spawn_id 4) match glob pattern "assword*:"? no
Password:
expect: does "Password: " (spawn_id 4) match glob pattern "assword*:"?
yes
expect: set expect_out(0,string) "assword:"
expect: set expect_out(spawn_id) "4"
expect: set expect_out(buffer) "Password:"
send: sending "gei.diela\r" to { 4 }

expect: does " " (spawn_id 4) match glob pattern "assword*:"? no
gei.diela

expect: does " gei.diela\r\n" (spawn_id 4) match glob pattern
"assword*:"? no
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/*
 * hmm, strange things occur here, "gwei.diela" is the password I
 * supplied to the spawned process, when did it become the spawned
 * process' output? :-)
 */

expect: timed out

expect: does " gei.diela\r\n" (spawn_id 4) match glob pattern
"assword*:"? no
expect: timed out

========End of Debugging output=====

Here are some info about the computer/os I am using, hope it may be
useful:

Distribution:   RH 5.0, fresh installation
Kernel:         2.0.33
Libc:           I believe most apps in RH 5 are using glibc2 (libc6)
gcc:            2.7.2(anyway, i didn't recompile packages, yet)
expect:         version 5.24
expect RPM:     expect-5.24-12
TCL:            8.0
TCL RPM:        tcl-8.0-12
Linux PAM:      0.59
PAM RPM:        pam-0.59-5

As always, comments/idea/feedback/pointer of info are always more than
welcome.  Please follow up or direct your email to

Regards
========
Gong Wei



Sat, 02 Sep 2000 03:00:00 GMT  
 Expect Script to Change Password

   We are having some problem while trying to write some simple
   password-changing expect script on a fresh installed RH5.0 machine.

   Problem Description:
   The script is simple.  It's intended to be run by user "nobody", with
   three arguments: username, oldpassword and newpassword. So it will
   first spawn a "su $user -c passwd" process, then it will supply old
   password twice, new password twice.

   But oddly enough, here is my debugging output:
   =====
   spawn su gwei -c /usr/bin/passwd
   parent: waiting for sync byte
   parent: telling child to go ahead
   parent: now unsynchronized from child
   spawn: returns {1698}

   expect: does "" (spawn_id 4) match glob pattern "assword*:"? no
   Password:
   expect: does "Password: " (spawn_id 4) match glob pattern "assword*:"?
   yes
   expect: set expect_out(0,string) "assword:"
   expect: set expect_out(spawn_id) "4"
   expect: set expect_out(buffer) "Password:"
   send: sending "gei.diela\r" to { 4 }

   expect: does " " (spawn_id 4) match glob pattern "assword*:"? no
   gei.diela

   expect: does " gei.diela\r\n" (spawn_id 4) match glob pattern
   "assword*:"? no
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   /*
    * hmm, strange things occur here, "gwei.diela" is the password I
    * supplied to the spawned process, when did it become the spawned
    * process' output? :-)
    */

This could happen if you send the password before passwd has turned
off echo.  An obvious fix to your script is to wait for the space at
the end of the prompt.  After all, if you're not waiting for the end
of the prompt, you might as well not be waiting for it at all.

I would hope that fixes it, but if not, then you must assume the
program simply doesn't make any guarantee about when it turns off echo
(very poor design) and sleep for a second or two before your send.

Don

   expect: timed out

   expect: does " gei.diela\r\n" (spawn_id 4) match glob pattern
   "assword*:"? no
   expect: timed out

   ========End of Debugging output=====

   Here are some info about the computer/os I am using, hope it may be
   useful:

   Distribution:   RH 5.0, fresh installation
   Kernel:         2.0.33
   Libc:           I believe most apps in RH 5 are using glibc2 (libc6)
   gcc:            2.7.2(anyway, i didn't recompile packages, yet)

Sounds like you are aware there was a problem with the libc on redhat
5.0.  However, I'm told it's a shared lib and doesn't require
recompilation.

Don

   expect:         version 5.24
   expect RPM:     expect-5.24-12
   TCL:            8.0
   TCL RPM:        tcl-8.0-12
   Linux PAM:      0.59
   PAM RPM:        pam-0.59-5

   As always, comments/idea/feedback/pointer of info are always more than
   welcome.  Please follow up or direct your email to

   Regards
   ========
   Gong Wei



Sat, 02 Sep 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Expect script that automates password changes

2. Using Expect to change passwords

3. Trying to write a password auto-entry expect script

4. expect setting a password called from perl script

5. Password security within Expect script

6. changing unix password via www python script

7. changing unix password via www python script

8. scripts to change passwords...

9. Starting Multiple Expect Scripts from a Single Expect Script

10. Expect scripts within expect scripts

11. Expect script calling Expect script

12. How to change current directory in Expect Script?

 

 
Powered by phpBB® Forum Software