#!/usr/bin/expect -f # # Copyright 2004 WPAD Limited. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # if { [llength $argv] != 1} { puts "usage: solsession " exit 1 } set hostname [lindex $argv 0] set timeout 10 set password "" catch {set password $env(IPMI_PASSWORD)} if { [llength $password] == 0} { puts "no IPMI password specified..." exit 1 } if {[catch {exec ipmitool -I lan -H $hostname -E sol setup} msg]} { puts stderr "Whilst enabling SOL on $hostname - got error:\r" puts stderr "$msg" exit 1 } #set timeout 10 set pid [spawn telnet localhost 623] expect timeout { puts "dpcproxy connection failed" kill $pid exit 1 } "Server: " send -- $hostname\r expect -exact $hostname expect timeout { puts "dpcproxy connection failed" kill $pid exit 1 } -exact "\r Username: " send -- "\r" expect timeout { puts "dpcproxy connection failed" kill $pid exit 1 } -exact "\r Password: " send -- $password send -- "\r" expect timeout { puts "dpcproxy connection failed" kill $pid exit 1 } -exact "\r\nLogin successful\r\n\r\n\r\ndpccli> " send -- "console\r" expect timeout { puts "dpcproxy connection failed" kill $pid exit 1 } -exact "console\r\n" set timeout 7 expect { "Active SOL failed*" { puts "Couldn't initiate SOL session - exiting" exec kill $pid exit 1 } timeout { #puts "Timed out - I'm assuming this is a good think, switching to interactive mode" } -re "^\[^A]" { #puts "dpcproxy didn't start to say the failure string, so I think we're OK"; } } interact