|
![]() |
|
Thread Tools | Rate Thread | Display Modes |
#16
|
|||
|
|||
Hi Todd! I am using the vbs version, and that did the trick! Thanks a lot!
|
#17
|
|||
|
|||
You are welcome hvh2000. I am glad I could help.
|
#18
|
|||
|
|||
host prompt changes
Hi Todd,
I ran into a bit of a problem with the vbscript version. I am issuing commands to a (cisco) device, and the script stops when I issue "config term", because the prompt changes from hostname# to hostname(config)#. How do I modify the script to continue executing commands when the prompt changes from # to config)#? Adding the current version I'm working with. I added cases for when I need to elevate privileges on a device to be able to work with it. Let me know if I need to clarify anything further. |
#19
|
|||
|
|||
Hi hvh2000,
There are many ways to accomplish your goal. I know that there is a thread that discusses this exact change. If I can find the thread, I will post it. The line that needs to be modified in the original script would be 251. Rather than waiting for the prompt, you could wait for all possible prompts. If strPrompt is defined as hostname#, then you could create a new variable by replacing the # with (config)#. For example: strConfigPrompt = Replace(strPrompt, "#", "(config)#")The ReadString() call would have multiple strings. For example: strResult = ReadString(strPrompt, strConfigPrompt)Does this help? Last edited by rtb; 08-14-2014 at 08:28 AM. |
#20
|
|||
|
|||
Thanks Todd!! That did the trick!
|
#21
|
|||
|
|||
Dynamic prompt
Todd,
I am trying to do the same thing, but the prompts are much more dynamic. I edited the script and added several prompts, but they literally change with every directory. Any idea how I could alter the script to provide support for dynamic prompts or perhaps trimming everything out except the #. Thanks |
#22
|
|||
|
|||
Hi aluminex,
Thanks for the post. The goal is to use something generic enough to work with a wide range of possibilities, but unique enough to prevent false positives. Is the # symbol unique enough that you the script won't find it in the output of a command that is run? What types of devices are you connecting to when using the script? Is it possible to change the shell prompt on the devices? |
#23
|
|||
|
|||
Quote:
Thanks for the reply. I am connecting to Fortigate firewalls (FortiOS), and Cisco routers. I think # would be unique enough... not certain though. |
#24
|
|||
|
|||
Hi aluminex,
Thanks for the update. You will have to run tests, but a simple way to test would be to comment out line 195, and add a line after it that sets strPrompt equal to what you want. For example: strPrompt = "#"Does this work for you? |
#25
|
|||
|
|||
Works great Todd! Thanks!
|
#26
|
|||
|
|||
Hi aluminex,
Thanks for the update. I am glad to hear that the change is working. Please remember, that this is a hardcoded string that is not terribly unique. If you get to a point where the script is not functioning as you expect, you may consider looking at the output to ensure that the "#" is not appearing before you expect it to appear (in the prompt). |
#27
|
|||
|
|||
Hi Todd!!
I am trying to use the vbs version of the script but not able to login to devices. I am suspecting that this script is based on ssh login to devices but my devices are only enabled for telnet access only.
Is there any version that uses telnet protocol to login to devices instead of ssh. |
#28
|
|||
|
|||
Hi aaakaundal,
Thanks for the post. Actually, if you look at the Connect() function in the VBScript version of the script, you will see on lines 429 to 437 that many different strings are handled. It is anticipated that Telnet connections should work as well. If you find that there is a response from the remote that isn't handled, you can add the new response and a new case to handle the response. Does this help? |
#29
|
|||
|
|||
Quote:
' ' If you want to authenticate with publickey authentication instead of ' password, in the assignment of strConnectString below, replace: ' " /AUTH password,keyboard-interactive /PASSWORD " & g_strPassword & _ ' with: ' " /AUTH publickey /I ""full_path_to_private_key_file"" " & _ strConnectString = _ g_strFirewall & _ " /TELNET " & g_strHost & " 23" ' Call the Connect() function defined below in this script. It handles ' the connection process, returning success/fail. If Not Connect(strConnectString) Then strErrors = strErrors & vbcrlf & _ vbtab & "Failed to connect to " & g_strHost & _ ": " & g_strError Else |
#30
|
|||
|
|||
Example script with Cisco device....
I am trying to use the example script (vbs) with a list of IP addreses for all of our Cisco switches. I have been able to get the script to work when using show commands. But now the script is failing when I try to use an tftp command after connecting to the Cisco switch.
What I am trying to do is tftp a copy of the startup config to a backup location. The command is .... copy startup-config tftp://tftp server address/folder/file name... While the command can be entered entirely on a single line the response back from the switch will still require that the return key be pressed 2 more time before the command is executed so I choose to enter the entire command with 3 different line.... 1. copy startup-config tftp:{enter} 2. [tftp servers ip address] {enter} 3. [name of file] which is a combo of IP address + strtup.cfg {enter} The script runs all the way through entering the first command then hangs. I suspect that the response back from the switch is causing the script to hang because it is not he normal # prompt. After the first command is entered the switch responds back with address or name of remote host []? (this is where the tftp server IP goes) but none of the other commands from the command file are entered. Is there a way to continue or should I look at creating a script from scratch ? |
![]() |
Tags |
example script |
Thread Tools | |
Display Modes | Rate This Thread |
|
|