expect实现交互式输入

一.用expect实现交互式输入

#!/usr/bin/expect -f
set LUKS_passphrase xxxx123
set Verify_passphrase xxxx123
spawn cryptsetup luksFormat /dev/vdb1

expect "Are you sure? (Type uppercase yes):"
set timeout 5
send "YES\r"

expect "Enter LUKS passphrase:"
set timeout 5
send "$LUKS_passphrase\r"

expect "Verify passphrase:"
set timeout 5
send "$Verify_passphrase\r"

send "exit\r"
expect eof

二.用shell脚本调用expect脚本

expect x.exp


本文转自 luoguo 51CTO博客,原文链接:http://blog.51cto.com/luoguoling/1721237


上一篇:【Android FFMPEG 开发】Android Studio 中 配置 FFMPEG 库最小兼容版本 ( undefined reference to 'atof' )


下一篇:使用PolarDB和ECS搭建门户网站