View Single Post
Old 03-22-2012, 11:10 AM
rtb rtb is offline
VanDyke Technical Support
Join Date: Aug 2008
Posts: 4,306
Hi djacoby,

I think that I would like to have you begin with a script that I know works, and we can add to it as you find features that you want to add. I have attached a script that illustrates how to handle authentication in the terminal window when connecting through a jump host. It has a Case...Statement that handles all possible responses from the remote host as defined in an array. In the script it handles SSH and Telnet, and you could pair it down if you want, but it should run even if you are just using Telnet.

Here is how you would accomplish your config writing goal in the script example:
            Case 1,2
                ' Found "-->" or "$" which in our example indicate successful
                ' authentications.
                ' Do work we need to complete on host including sending the exit
                ' command which will disconnect us from the secondary host
                ' allowing us to loop up to the top and connect to the next
                ' host.
                crt.Screen.Send "no cli-paging " & vbcr
                crt.Screen.WaitForString "#"
                crt.Screen.Send "sh run" & vbcr

                crt.Screen.WaitForString vbcr
                strResult = crt.Screen.ReadString "#"
                objFile3.Write strResult
                ' Now that we have done the necessary work (including waiting
                ' for an indication that the last command we sent above has
                ' completed, send "exit" to disconnect from secondary host.
                crt.Screen.Send "exit" & vbcr
                ' Wait for an indication that the exit command was successful
                ' before attempting to connect to next host.
                crt.Screen.WaitForString g_strMainPrompt
                ' Exit inner Do..Loop since we are done with the success case.
                Exit Do
You will need to customize the possible prompts you might see in your environment, and you will need open your files rather than use the array of defined hosts.

Does this help you get a running script?

If so, let me know and I will move to the Excel code.
Attached Files
File Type: txt JumpHost-HandleSecondaryHostConnectionAttempts.vbs.txt (7.0 KB, 313 views)

VanDyke Software
Technical Support
Reply With Quote