zoukankan      html  css  js  c++  java
  • 使expect脚本传回返回值

    使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

  • 相关阅读:
    Rock the Tech Interview
    k-d Tree in TripAdvisor
    Randomized QuickSelect
    Kth Smallest Element in Unsorted Array
    Quick Sort
    LRU Cache 解答
    Implement Queue using Stacks 解答
    Implement Stack using Queues 解答
    ListNode Review ReverseListNode
    BackTracking
  • 原文地址:https://www.cnblogs.com/mydomain/p/3032854.html
Copyright © 2011-2022 走看看