首页 > 其他 > 详细

expect实现交互式输入

时间:2015-12-09 19:52:22      阅读:236      评论:0      收藏:0      [点我收藏+]

一.用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

本文出自 “自动化rolin” 博客,请务必保留此出处http://luoguoling.blog.51cto.com/1568501/1721237

expect实现交互式输入

原文:http://luoguoling.blog.51cto.com/1568501/1721237

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!