I know this may not be the correct forum for this question, but I just can't find where the appropriate place to ask would be. I'm trying to move an expect script from and older non-fedora linux box to a new fedora box. It's just not working. I'm thinking it has less to do with expect and more to do with the passwd function on fedora, but I'm not sure. What I'm trying to do is call the expect script to set a password from inside a customized useradd fuction. This is what my scipt looks like: !/usr/bin/expect -f ;# autopass created 7-27-97 exp_internal 1
set name [lindex $argv 0] set pass [lindex $argv 1] set bad 0
#spawns passwd and sends all the info
log_user 1
spawn /usr/bin/passwd $name
expect "password:" {send "$pass\r"}
expect { "BAD" {set bad 1} "password:" {send "$pass\r"} }
#puts "$bad"; if {$bad == 1} { expect "password:" {send "$pass\r"} expect "password:" {send "$pass\r"} } expect "successfully." {puts "passwd for $name changed.";} close
And this is my output...it doesn't appear as if passwd is accepting the input: [root@hedwig anner]# /usr/local/bin/autopass anner try12 Application initialization failed: no display name and no $DISPLAY environment variable spawn /usr/bin/passwd anner parent: waiting for sync byte parent: telling child to go ahead parent: now unsynchronized from child spawn: returns {12118}
expect: does "" (spawn_id exp4) match glob pattern "password:"? no Changing password for user anner.
expect: does "Changing password for user anner.\r\n" (spawn_id exp4) match glob pattern "password:"? no New UNIX password: expect: does "Changing password for user anner.\r\nNew UNIX password: " (spawn_id exp4) match glob pattern "password:"? yes expect: set expect_out(0,string) "password:" expect: set expect_out(spawn_id) "exp4" expect: set expect_out(buffer) "Changing password for user anner.\r\nNew UNIX password:" send: sending "try12\r" to { exp4 }
expect: does " " (spawn_id exp4) match glob pattern "BAD"? no "password:"? no try12
expect: does " try12\r\n" (spawn_id exp4) match glob pattern "BAD"? no "password:"? no expect: timed out
expect: does " try12\r\n" (spawn_id exp4) match glob pattern "successfully."? no expect: timed out
Any help would be appreciated.