expect 使用心得

来源:互联网 发布:coreldraw mac中文版 编辑:程序博客网 时间:2024/04/26 11:57

安装软件 yum install expect

例子 ssh自动登录

#!/usr/bin/expect -fset timeout 2spawn ssh root@192.168.1.100expect {"*yes/no" { send "yes\r"; exp_continue }"*password:" { send "password1\r" }timeout { send \003  }}interact
注意空格以及双引号的使用,校验很严格,最后的interact是必须的

这里用到了timeout

例子 expect发送ctrl+c命令

send \003

例子

0 0
原创粉丝点击