使expect脚本传回返回值

1、使用expect示例:

spawn $SPAWN_CMD

expect {

        -re "Enter password for new role:" {

                send "$PWPROMPT\n"

                exp_continue

        } -re "Enter it again:" {

                send "$PWPROMPT\n"

                exp_continue

        } -re "Password(.*)" {

                send "$PASSWORD\n"

                exp_continue

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

                send "$PASSWORD\n"

                exp_continue

        } eof

}

2、返回值

spawn true

expect eof

catch wait result

exit [lindex $result 3]

Exits with 0.

***

spawn false

expect eof

catch wait result

exit [lindex $result 3]

Exits with 1.

原文

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2021-05-20
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
相关资源
相似解决方案