[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

expect : probleme avec passwd



Bonjour

Je cherche a utiliser expect pour la mise a jour automatique de mot de passes (ou autre)
voici le petit script

#!/usr/bin/expect -d
set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect -re ".*password:"
send "$password\r"
expect -re ".*password:"
send "$password\r"
expect eof


Malheureusement de temps à autres (assez souvent) le script ne marche pas

comme si expect attendait une ligne blanche apres la premiere entree du password
(pkoi) et se desynchronisait. (je veux bien "ruser" en prenant en compte cette ligne blanche au cas ou mais j aimerais bien comprendre de quoi il retourne

voici le resultat produit en mode debug :

./pass1 steph steph
expect version 5.43.0
argv[0] = /usr/bin/expect  argv[1] = -d  argv[2] = ./pass1  argv[3] = steph  arg v[4] = steph
set argc 2
set argv0 "./pass1"
set argv "steph steph"
executing commands from command file ./pass1
spawn passwd steph
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {31841}

expect: does "" (spawn_id exp6) match regular _expression_ ".*password:"? no
Enter new UNIX password:
expect: does "Enter new UNIX password: " (spawn_id exp6) match regular expressio n ".*password:"? yes
expect: set expect_out(0,string) "Enter new UNIX password:"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "Enter new UNIX password:"
send: sending "steph\r" to { exp6 }

expect: does " " (spawn_id exp6) match regular _expression_ ".*password:"? no
steph

expect: does " steph\r\n" (spawn_id exp6) match regular _expression_ ".*password:" ? no
expect: timed out
send: sending "steph\r" to { exp6 }

Retype new UNIX password: expect: timed out
write() failed to write anything - will sleep(1) and retry...


Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
Reply to: