shell写自动安装脚本自动读取license和自动输入回车
#!/usr/bin/expectset timeout 45 #有些命令需要执行比较久,这里设置45以避免expect执行命令过程会退出
set rrdspath #传参,下面会再举例说明
set pearpath
spawn ./install.sh -i #需要交互的命令
expect "Press enter to continue." #有出现的字符串
send "\n" #出现上面字符串之后发送回车
expect "modification follow." #此为读取license底部出现的行
send " " #发送多个空格
send " "
send " "
send " "
send " "
expect "default to *:" #直到此处,要求输入选择
send "y\r" #自动输入
中间还有很多略过......
expect eof
页:
[1]