vendredi 5 octobre 2018

Expect not matching

I had an expect script that was working; it contained the following lines:

expect "\[Y\]\> "
send "n\r"

The OS I'm interacting with changed, I now have a mixed environment of boxes. Some now have "[Y]>", some have "[1]>" at the point I'm trying to deal with.

I tried changing the code to:

expect {
        "\[Y\]\> " { send "n\r";exp_continue }
        "\[1\]\> " { send "2\r";exp_continue }
}

however, running in debug I see:

"Choose the password option:
1. Mask passwords 
2. Plain passphrases
[1]>
expect: does "s...ses\r\n[1]> " (spawn_id exp5) match glob pattern "[Y]> "? no 
"[1]> "? no
expect: timed out"

I don't understand why the revised code is not working, for either "[Y]> " or "[1]> ", when "[Y]> " was being matched before the 'else' statement was introduced.

Aucun commentaire:

Enregistrer un commentaire