VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   General (https://forums.vandyke.com/forumdisplay.php?f=11)
-   -   loop failed to execute by python (https://forums.vandyke.com/showthread.php?t=13544)

somenasty 05-15-2019 02:39 AM

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()


jpellegrini 05-15-2019 08:56 AM

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



All times are GMT -6. The time now is 02:09 PM.