使用腳本進入一個命令行控制臺,并預設執行的命令列表
參考1:https://codeday.me/bug/20170628/32557.html
參考2:https://avdeo.com/2009/08/14/spawn-expect-send-and-interact/
主要是使用Unix內置的expect程序。
在腳本之前 寫 #!/usr/bin/expect 或 #!/usr/bin/expect -f 均表明該腳本使用expect執行。
expect可以識別spwn,expect,interact,send等命令,還有set promt等。
使用spwn命令啟動一個外部程序。
使用expect等待將要出現的字符串,可以使用通配符,只有出現了匹配的字符串,才繼續執行腳本中下一條命令。
使用send發送需要外部程序執行的命令。
man7上有詳細介紹 http://man7.org/linux/man-pages/man1/expect.1.html
posted on 2019-04-01 11:14 longbigfish 閱讀(348) 評論(0) 收藏 舉報
浙公網安備 33010602011771號