Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2019, 03:39 AM
somenasty somenasty is offline
Registered User
 
Join Date: May 2019
Posts: 1
loop failed to execute by python

Code:
# $language = "Python"
# $interface = "1.0"

# Connect to a telnet server and automate the initial login sequence.
# Note that synchronous mode is enabled to prevent server output from
# potentially being missed.

def main():

	crt.Screen.Synchronous = True

	# connect to host on port 23 (the default telnet port)
	#count = crt.Arguments
	count = 0
    while count<5 :
	  # crt.Screen.WaitForString("Enter password>")
	  # crt.Screen.Send("arristi\r")
	    crt.Screen.WaitForString("Console>")
	    crt.Screen.Send("sta\r")
        count = count +1
	crt.Screen.Synchronous = False


main()

Last edited by jdev; 05-15-2019 at 09:39 AM. Reason: Use code tags around code
Reply With Quote
  #2  
Old 05-15-2019, 09:56 AM
jpellegrini jpellegrini is offline
Registered User
 
Join Date: Mar 2019
Posts: 20
Hi somenasty,

You mention that the loop is failing to execute.

What exactly is it failing at doing?

Does it give you any error message or any information?

I notice some indentation issues in your script. In Python, white space is important because it is used as the delimiter between scopes (ie: what is in the function main() as a whole vs. what is in the while loop). Therefore, the while loop may execute better if you do the following:

Code:
while count<5 :
		crt.Screen.WaitForString("Console>")
		crt.Screen.Send("sta\r")
		count = count + 1
__________________
Thanks,
--Jon

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply

Tags
python2.6


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

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 09:23 PM.