亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2592 | 回復(fù): 2
打印 上一主題 下一主題

[其他] expect接受鍵盤輸入的腳本問題 [復(fù)制鏈接]

論壇徽章:
1
程序設(shè)計版塊每日發(fā)帖之星
日期:2016-05-04 06:20:00
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2015-06-09 11:43 |只看該作者 |倒序?yàn)g覽
腳本如下:

#!/usr/bin/expect
spawn command
expect "number1"
send "-20\r"
expect "number2"
send "20\r"
expect "number3"
send "20\r"
interact

問題:

因?yàn)閏ommand執(zhí)行后,需要從鍵盤接收多個參數(shù),每個參數(shù)輸入后都要敲回車,所以不能用管道(至少我不會)。

然后我用expect,當(dāng)屏幕顯示“number1” 時,需要鍵盤輸入一個數(shù)值。如果鍵盤輸入的數(shù)值是正數(shù),比如“20”,腳本正常運(yùn)行,沒問題。但是如果這個數(shù)值是復(fù)數(shù),比如send "-20\r",這個是時候就會提示錯誤,錯誤提示內(nèi)容如下:

": must be -i, -h, -s, -null, -0, -raw, -break, or --
    while executing
"send "-20\r""

求解答呀!

論壇徽章:
145
技術(shù)圖書徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11獅子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龍
日期:2014-01-08 15:26:12技術(shù)圖書徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
2 [報告]
發(fā)表于 2015-06-09 12:22 |只看該作者
本帖最后由 jason680 于 2015-06-09 12:23 編輯

回復(fù) 1# vcuteym

send "-20\r"

change to

send -- "-20\r"
   

http://www.tcl.tk/man/expect5.31/expect.1.html
...
send
[-flags] string
Sends string to the current process.For example, the command
    send "hello world\r"
...
The -- flag forces the next argument to be interpreted as a string rather than a flag. Any string can be preceded by "--" whether or not it actually lookslike a flag.  This provides a reliable mechanism to specify variable stringswithout being tripped up by those that accidentally look like flags.(All strings starting with "-" are reserved for future options.)

論壇徽章:
1
程序設(shè)計版塊每日發(fā)帖之星
日期:2016-05-04 06:20:00
3 [報告]
發(fā)表于 2015-06-09 12:25 |只看該作者
回復(fù) 2# jason680


    真是高手中的高手呀!
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP