簡體   English   中英

我在OSX的bash中執行Expect命令時遇到問題

[英]I'm having problems executing the expect command in bash on OSX

我需要一些幫助。

操作系統 :Mac oSX 10.9.4

我正在運行bash腳本,如下所示: sh create-emulator.sh AVD_16 14 / usr / local / ks-test-automation / avd-lib / x86 QVGA

編碼:

create_emulator() {
    android create avd -n $Emulator -t $Target -p $Location --abi $Processor --skin $Skin --force
    expect "Android 4.4.2 is a basic Android platform." 
    expect "Do you wish to create a custom hardware profile [no]" 
    send "no\n"
}

main_method() {
    create_emulator
}

Emulator="$1"
Target="$2"
Location="$3"
Processor="$4"
Skin="$5"
main_method

使用ctrl + c退出腳本后的輸出:

Couldn't read file "Android 4.4.2 is a basic Android platform.": no such file or directory
couldn't read file "Do you wish to create a custom hardware profile [no]": no such file or directory
/usr/local/ks-test-automation/shell-script-lib/create-emulator.sh: line 14: send: command not found

提前致謝

對於我了解您要執行的操作,您的語法絕對錯誤。 掃描了expect手冊頁后 ,我認為正確的語法是這樣的:

create_emulator {
    expect <<END
        spawn android create avd -n $Emulator -t $Target -p $Location --abi $Processor --skin $Skin --force
        expect "Android 4.4.2 is a basic Android platform." 
        expect "Do you wish to create a custom hardware profile \[no\]" 
        send "no\r"
        expect eof
END
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM