Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-13-2018, 11:39 AM
Hang Hang is offline
Registered User
 
Join Date: Jul 2016
Posts: 21
Post scripting hanging at if waitforstring statement

I was wondering if you guys have a suggestion for a better way of cycling through password.

My current script always hang at the if statement.

Here is my code:
Code:
prompt = "A:"
currentTab = crt.GetScriptTab()
password = ["wrongPass", "rightPass"]


def main():		
	x = 0
	currentTab.Screen.Synchronous = True		
	currentTab.Screen.Send("kernel\r")
	while currentTab.Screen.WaitForString("assword:") == True:
		currentTab.Screen.Send(password[x]+"\r")
		if currentTab.Screen.WaitForString(prompt) == True:			
			x = x + 1		
			currentTab.Screen.Send("kernel\r")	
		else:
			break

	currentTab.Screen.Send("finished")
	
main()
Here is my output:
Quote:
*A:# kernel
Password:
MINOR: CLI Unidentified command.
*A:# kernel
Password:
Type "exit" to return to CLI.
1->
As you can see the right password was enter on the second try. However, the script will hang at the waitforstring(prompt) line of code and never send the "finished" string. It is waiting for "A:" but we already log into the kernel and it doesn't go to the else statement to break out of the while loop.
Reply With Quote
 

Tags
if statement , waitforstring


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:08 AM.