天天看點

使expect腳本傳回傳回值

使expect腳本傳回傳回值

1、使用expect示例:

spawn $SPAWN_CMD

expect {

        -re "Enter password for new role:" {

                send "$PWPROMPT\n"

                exp_continue

        } -re "Enter it again:" {

        } -re "Password(.*)" {

                send "$PASSWORD\n"

        } -re "Password(.*):" {

        } eof

}

2、傳回值

spawn true

expect eof

catch wait result

exit [lindex $result 3]

Exits with 0.

***

spawn false

Exits with 1.

原文

http://stackoverflow.com/questions/3299502/how-to-return-spawned-process-exit-code-in-expect-script

繼續閱讀