Problem with if/else
- From: "Dan" <dan63127@xxxxxxxxx>
- Date: 29 Mar 2007 08:37:38 -0700
First of all, thanks to everyone who has helped me on the couple of
previous problems I've posted here. Second, I've beaten my head
against the wall until it bleeds -- it's time to ask for more
help. :-)
I've got some code that ssh's into a network device and grabs some
output. This output is the parsed using the expression below (which
works only because of your help!). Then I run a ping test against the
hosts, and take them down, or bring them up based on the response.
However, what I want to avoid is inadvertently bringing up a host that
was administratively taken down for maintenance. If the host is down
for maintenance, then $pause will equal either "hard" or
"soft" (exactly). If it says anything other than those two strings,
including "hard(Config:none)" then I want to proceed with the ping
test.
Here is the code I am having problems with.
---code snip---
while { 1 } {
expect {
-re {([0-9]+.[0-9]+.[0-9]+.[0-9]+):([0-9]+)\s+([0-9]+)\s+
([0-9]+)\s+([0-9]+)\s+(\w+)\s+(\
w+)} {
set host $expect_out(1,string)
set port $expect_out(2,string)
set weight $expect_out(3,string)
set maxconn $expect_out(4,string)
set priority $expect_out(5,string)
set status $expect_out(6,string)
set pause $expect_out(7,string)
}
-re $my_prompt { break }
}
if {$pause = "hard"} {
puts "Target is administratively hard paused --
skipping."
} elseif {$pause = "soft"} {
puts "Target is administratively soft paused -- skipping."
} else {
do_ping $host $port
}
}; # while
---code snip---
Here are some examples of output I am grepping
---expect_in snip---
Targethosts:
IP:Port Weight Maxconn Priority Status Pause
----------------------------------------------------------------------
172.16.0.100:4500 1 200 1 Up none
172.16.0.101:4500 1 200 1 Paused hard
172.16.0.102:4500 1 200 1 Paused soft
172.16.0.103:4500 1 200 1 Paused
hard(Config:none)
----------------------------------------------------------------------
---expect_in snip---
I have also tried:
if {$pause != "hard" || $pause !="soft" } {
do_ping $host $port
}
if {($pause != "hard") || ($pause !="soft") } {
do_ping $host $port
}
if {$pause != "hard"} || {$pause !="soft"} {
do_ping $host $port
}
I've tried everything I can think of. I'm sure this is fairly simple,
but so am I. :-)
Thanks in advance!
Dan
.
- Follow-Ups:
- Re: Problem with if/else
- From: Uwe Klein
- Re: Problem with if/else
- Prev by Date: Re: Valid channels for use with tls::import?
- Next by Date: Re: reusing "code entities" without oop
- Previous by thread: GiD
- Next by thread: Re: Problem with if/else
- Index(es):
Relevant Pages
|