|
#1
|
|||
|
|||
if statement help ,
Running the latest secureCRT on MAC.
Code:
objNewTab.Screen.WaitForString("# ") objNewTab.Screen.Send("ssh " + host + '\r') objNewTab.Screen.WaitForString("word: ") objNewTab.Screen.Send("mypass" + chr(13)) if objNewTab.Screen.WaitForString("word: "): objNewTab.Screen.Send(chr(3)) objNewTab.Screen.WaitForString("# ") objNewTab.Screen.Send("ssh " + host + '\r') objNewTab.Screen.WaitForString("word: ") objNewTab.Screen.Send("mypass" + chr(13)) objNewTab.Screen.WaitForString("$ ") objNewTab.Screen.Send("su - root" + chr(13)) objNewTab.Screen.WaitForString("word: ") objNewTab.Screen.Send("mypass" + chr(13)) objNewTab.Screen.WaitForString("# ") objNewTab.Screen.Send(chr(13)) ##else: if objNewTab.Screen.WaitForString("# ") : objNewTab.Screen.Send(chr(13)) objNewTab.Screen.WaitForString("# ") objNewTab.Screen.WaitForString("echo test" + chr(13)) objNewTab.Screen.Send(chr(13)) Issue is i cant get it to drop into the second part I have tried else , elif, if not with no luck. Code:
##else: if objNewTab.Screen.WaitForString("# ") : objNewTab.Screen.Send(chr(13)) |
#2
|
|||
|
|||
Hi rleon,
When you say you can't get it to drop into the second part do you mean after: Quote:
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Hi ekoranyi
That is correct I tried elsif if .. if not , == true and nothing works. Code:
if objNewTab.Screen.WaitForString("# ") : |
#4
|
|||
|
|||
rleon,
What language are you using? What are you trying to accomplish? Does the WaitForString in the second to last line of the first block seem to work as desired? Quote:
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#5
|
||||
|
||||
When you need to perform a branch based on "thingA" vs "thingB" arriving from the remote, you cannot do so using nested WaitForString() calls. You must use WaitForStrings() instead, using the Screen's MatchIndex property to determine which of your strings was found.
When something like "thingA" has already shown up on the screen, it's too late to call WaitForString("thingA"); "thingA" has already arrived, been displayed to the screen, and cannot be WaitForString'd.In your case, you'll need a construct that uses WaitForStrings to wait for all possible things that you need to branch on, as exemplified in the posted example in the scripting "sticky": Example: Jump Host - Handle Secondary Host Connection Attempts --Jake
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|