Problem with if/else



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

.



Relevant Pages

  • Re: External drives not installing or working properly on USB
    ... with the USB system before but these disappearred when I disabled the ... Only one of the five host controllers is connected to the 6 ... work on any port on the PC? ... operating system to recognise the four additional 'drives'. ...
    (microsoft.public.windowsxp.general)
  • Re: A firewall wont stop this one
    ... On top of that I implement IPF on each host ... >> for further access control to limit NFS, ... By restricting access to the NFS server. ... >> via port filtering that only allowed specific hosts rather than all. ...
    (alt.computer.security)
  • Re: /etc/hosts.equiv & .rhosts
    ... want to login at another host, that host needs the first host's name ... best to allow key-only login so hackers can't ... on the port 22 as it WILL be messed with all day long. ... # Protocol 2 only ...
    (comp.os.linux.security)
  • Re: REMOTE DESKTOP NOT WORKING ANY LONGER PLEASE HELP!
    ... I understand that you have checked in the registry *which* port is ... Is the host located at your work? ... be a centrally managed GPO which disables Remote Desktop ... Noest MCSE, CCEA, Microsoft MVP - Terminal Server ...
    (microsoft.public.windows.terminal_services)
  • Re: REMOTE DESKTOP NOT WORKING ANY LONGER PLEASE HELP!
    ... Yes the host is listening on port 3389 the default and I verified this. ... Try connecting again. ...
    (microsoft.public.windows.terminal_services)