Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with expect script

Status
Not open for further replies.

uuperl

Programmer
Feb 20, 2006
33
US
I have following expect script, I need help to get uname -m variable and assign to if statement.

Thanks!

#!/usr/bin/expect

set USER [lindex $argv 0]
set USER_PASS [lindex $argv 1]

set fid [open /path/iplist.dat]
set contents [read -nonewline $fid]
close $fid

foreach IPADDR [split $contents "\n"] {
spawn ssh $USER@$IPADDR
expect {
"assword:" {
send "$USER_PASS\r"
}
"you sure you want to continue connecting " {
send "yes\r"
expect "assword:"
send "$USER_PASS\r"
}
}

# how do I get uname -m here #

if { ["$HVAR" = "A"] } {
do some action here
} else {
do some action here
}
}
expect eof
 
You can use "lsb_release -a" to determine what linux distro you have, but it is a bit verbose.
lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.6 (squeeze)
Release: 6.0.6
Codename: squeeze


Use "lsb_release -s -c" to get just the codename.

You can use "$(lsb_release -s -c)" to get just the codename as a variable in your if statement.

You could also use "$(uname -n)" as a variable in your if statement as well.


Cybex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top