expect语言用来实现自动和交互式任务进行通信,而无需人的干预。
#!/usr/bin/expect //告诉操作系统脚本里的代码使用那一个shell来执行
set ip 192.168.1.156 //变量赋值
set pass 123.com
set timeout 30 //设置超时时间
spawn ssh root@$ip //给ssh运行用来传递交互指令
expect {
"(yes/no)" {send "yes\r"; exp_continue}
"password:" {send "$pass\r"}
}
expect "root@" {send "df -h\r"} //执行交互动作
expect "root@" {send "exit\r"}
expect eof
shell基础day11
原创
©著作权归作者所有:来自51CTO博客作者kooffe2的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:shell基础day10
下一篇:shell习题DAY12
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Day04 Docker
Docker
docker Docker 系统资源 -
shell训练营 Day11
shell编程基础实践
shell linux -
Spring学习-day11
Aop的理解
Spring day11