Chinaunix首页 | 论坛 | 博客
  • 博客访问: 820094
  • 博文数量: 188
  • 博客积分: 4433
  • 博客等级: 上校
  • 技术积分: 1905
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-14 07:14
个人简介

linux

文章分类

全部博文(188)

文章存档

2016年(6)

2015年(22)

2014年(18)

2013年(5)

2012年(125)

2011年(10)

2010年(2)

分类: Python/Ruby

2012-05-17 14:20:51

一个简单的expect脚本。expect在不是root用户情况下,据说很慢。。
强烈推荐使用perl的expect,速度快很多。

#!/usr/local/bin/expect
set timeout 40
#$argv 0 means the 1st argument, give its value to variable host
set host [lindex $argv 0]
#run the shell command
spawn scp ./nrpe_RHEL6_x86_.tar.gz user@$host:/tmp
expect {
        "/no)?" {send "yes\r";exp_continue}     
        "assword:" {send "Password\r";exp_continue}
        }
spawn ssh user@$host
expect {
        "/no)?" {send "yes\r";exp_continue}     
        "assword:" {send "Password\r";exp_continue}
        }
expect "$" 
        send "sudo su -\r"
expect "#"
        send "cd /tmp\r"
        send "yum -y install redhat-lsb\r"
        send "yum -y install openssl\r"
        send "./install Linux\r"
        send "exit\r"
expect eof
阅读(1023) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~