Chinaunix首页 | 论坛 | 博客
  • 博客访问: 484185
  • 博文数量: 67
  • 博客积分: 2952
  • 博客等级: 少校
  • 技术积分: 679
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-24 10:50
文章分类

全部博文(67)

文章存档

2011年(9)

2010年(36)

2009年(8)

2008年(5)

2007年(5)

2006年(4)

我的朋友

分类:

2010-12-23 10:40:20

Cisco UCS box already included CIMC, the we can write some script to change boot order by CIMC automatically. it is useful for PXE installation.


#!/usr/bin/expect

if {$argc<4} {

        puts stderr "Usage: $argv0 ip login passwaord option(pxe/hdd)"
        exit 1
}

set timeout 600

set IP        [lindex $argv 0]
set LOGIN    [lindex $argv 1]
set PASSWORD    [lindex $argv 2]
set OPTION [lindex $argv 3]

set flag 1
spawn ssh -t -p 22 $IP -l $LOGIN
while {$flag > 0} {
    expect {
        "\(yes\/no\)\?" { send "yes\r" }
                "assword:" { send "$PASSWORD\r"; set flag 0}
        timeout exit
    }
}

expect "#" { send "scope bios\r" }
if { $OPTION == "pxe"} {
    expect "#" { send "set boot-order pxe,hdd,cdrom,fdd,efi\r" }
} else {    
    expect "#" { send "set boot-order hdd,pxe,cdrom,fdd,efi\r" }
}
expect "#" { send "commit\r" }
expect "#" { send "top\r" }
expect "#" { send "scope chassis\r" }
expect "#" { send "power cycle\r" }
expect "want to continue?" { send "y\r" }
expect "#" { send "exit\r" }
expect "#" { send "exit\r" }


阅读(750) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~