0

my objective is to check if the switch prompt either ">" or "#" if prompt to ">" to send enable password then the command. if the switch prompt to "#" send just the command. but some reason go to directly to the command with out checking the condition.

  `  result = crt.Screen.WaitForString ([">","#"])
                If (result=1) Then  
                crt.Screen.Send chr(13)
                crt.Screen.Send "XXXXX" & chr(13)
                crt.Screen.WaitForString "Password: "
                crt.Screen.Send "a" & chr(13)
                crt.Screen.WaitForString "#"
                End If
               '++++++++++Now Send the command ++++++++++
         crt.Screen.Send "sh ver" & chr(13)
         crt.Screen.WaitForString vbcr
             strReadScreen = crt.Screen.ReadString("#")`
eli1128
  • 134
  • 1
  • 2
  • 11

1 Answers1

1

Even if the condition is checked it may fail or not, the command is always executed. Try to check for '>" first, then make your special stuff ... then check for both and call command

if(==">"){
 // do stuff here
}
if(=="#" || ==">"){
 // send command
}

">" and "#" would mean result==1 or result==2 in your code.

Lemonade
  • 503
  • 2
  • 8