VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Python Scripting trying to clone session more than 9 times (https://forums.vandyke.com/showthread.php?t=13921)

rlupi001 10-05-2019 01:38 AM

Python Scripting trying to clone session more than 9 times
 
Hello,

First of all i'd like to thank anyone that can help me with this.

I am running a script that I want to take a list of hosts and run a session into a step server and clone this session multiple times in order to login to each host in my list. However, i find that after 9 cloned tabs my connections seem to not execute properly anymore and just skip each host to the end of the file..

Is there a limit that is going on here that does not let me open and send cmds to more then 9 cloned tabs/windows? Here is my code:
Code:

sessionsFileName = os.path.expanduser("~") + "\SessionList.txt"
        if not os.path.exists(sessionsFileName):
                crt.Dialog.MessageBox(
                        "Session list file not found:\n\n" +
                        sessionsFileName + "\n\n" +
                        "Create a session list file as described in the description of " +
                        "this script code and then run the script again.")
                return

        sessionFile = codecs.open(sessionsFileName, "r", "utf-8")
        sessionsArray = []

        for line in sessionFile:
                session = line.strip()
                if session:        # Don't add empty lines/sessions
                        sessionsArray.append(session)

        sessionFile.close()

        # Connect to each session and issue a few commands, then disconnect.
        Blahship = crt.Session.ConnectInTab("/S Blah-Blah\Blah-Blah")
        Blah2ship = crt.Session.ConnectInTab("/S Blah-CONSOLE\Blah-Blah")
        for session in sessionsArray:
                try:
                        #crt.Dialog.MessageBox("Connecting to Session: " + session)
                        t = session.split()
                        tt = t[0]
                        console = t[1]
                        if console.startswith("11.2."):
                                drone = Blah2ship.Clone()
                        else:
                                drone = Blahship.Clone()
                        #drone.Screen.Synchronous = True
                        #drone.Screen.WaitForCursor(10)
                        drone.Caption = tt
                        drone.Screen.Send("/home/fjordman/dist/inception/inception " + console + "\r")
                        drone.Screen.WaitForString("Select a reality: ", 10)
                        drone.Screen.Send("f\r")
                except ScriptError:
                        crt.GetLastErrorMessage()


bgagnon 10-06-2019 04:31 PM

Hi rlupi001,

What version of SecureCRT are you using?

Do you get an error when you try to connect to the 10th clone? (If so, what's the error?)

Do you also get this error if you make 10 clones of a tab manually?

If so, then it is likely a limitation imposed by the remote server.

bgagnon 10-09-2019 09:18 AM

Hi rlupi001,

To clarify:
Quote:

I don't get any error message after the 5th session window is cloned...
Do you get any error message at any time?

Other than having synchronous commented out:

#drone.Screen.Synchronous = True
I don't see anything wrong with the script.

Are you sure the script completes?

Is Cancel available from the Script menu when it stops cloning the sessions?

If not, I would suggest you see if the results are any different in v8.5.4, the current, official release.


All times are GMT -6. The time now is 02:40 AM.