|
![]() |
|
Thread Tools | Rate Thread | Display Modes |
#61
|
|||
|
|||
Issue has been resolved. Thanks for your fast and responsive email support!!
|
#62
|
|||
|
|||
Thanks for posting Damon.
For anyone reading this, the problem was with the Default.ini file. There was something in the file that was preventing the script from running as expected. |
#63
|
|||
|
|||
Is it possible to execute this script within the existing Tab.
Normally to access my routers or switches I need to first login to a linux server and from there only I want to now be able to loop the devices in hosts.txt all in the same tab |
#64
|
|||
|
|||
Hi emexy,
The VBScript version uses ConnectInTab(), but can also use a firewall/proxy. The Python version uses ConnectInTab(), but doesn't have the ability to use a firewall/proxy. It is possible to modify the example to work in an existing tab, but the modifications you would need to make will likely be significant. Do you intend to use an SSH client on the jump host or would it be possible to connect through the jump host using SSH port forwarding (tunneling)? Last edited by rtb; 05-06-2015 at 09:15 AM. Reason: editing for more accuracy and completeness |
#65
|
|||
|
|||
Thanks for your help I am now using the VBScript version and that works fineafter I setup the SOCKs proxy and the firewall rule on port 1080. On its own I can connect to the devices but when i run the script i get the error "Invalid command line option SSH2"
I think the problem is here strConnectString = g_strFirewall & _ " /SSH2 /ACCEPTHOSTKEYS" & _ " /L " & g_strUsername & _ " /AUTH password,keyboard-interactive /PASSWORD " & g_strPassword & _ " " & g_strHost |
#66
|
|||
|
|||
Hi emexy,
If you message box the connect string, what do you see? You can add the following line of code just after the line you posted to see what the connect string contains: MsgBox strConnectString NOTICE: The requested troubleshooting data may include sensitive information (usernames, passwords, publicly-accessible host names or IP addresses, etc.). |
#67
|
|||
|
|||
This is what is shows
Firewall Name /SSH2 /ACCEPTHOSTKEYS /L myusername /AUTH password,keyboard-interactive /PASSWORD mypassword mydevicename |
#68
|
|||
|
|||
Hi emexy,
It seems like the problem may be higher up in the script. Lines 47 and 48 should look similar to the following: g_strFirewall = " /FIREWALL=myFireWallName "If you removed the " /FIREWALL=" portion of the string on line 47, then you will need it add it back to the string. Also, if you have a space in the firewall name, you will need to quote that. For example: " /FIREWALL=""myFireWallName"" "Does this help resolve the issue? Last edited by rtb; 05-06-2015 at 12:01 PM. |
#69
|
|||
|
|||
Thanks a lot, It was indeed the FIREWALL line. I adjusted that and it worked
Note: This is a quick help for anyone else when creating firewall name avoid spaces I previously used g_strFirewall = " /FIREWALL=Masters Firewall" but this failed and when i did the MsgBox strConnectString i realised it taking the first part only and was showing only "Masters" So I changed the name to "MastersFirewall" removing the space and it work |
#70
|
|||
|
|||
Hi emexy,
Thanks for the update. I am glad to hear that you have the script working. As a note, I edited my previous post to illustrate how one can handle spacing in the firewall name. It turns out that I was editing while exemy was posting success and his caveat. Using no space in the firewall name and quoting the firewall name are both valid possibilities. |
#71
|
|||
|
|||
When i run the script to excute the following command
the output is given as hostname>sh vlans vlanteachers 2178 vlanstudents 2129 {master:0} hostname> I am trying to retrieve for each line of output only the first part which is the vlan name and i need this only to be written to the log file. I Have tried using Split() but that didn't work. Also is there a way to filter out that last entry {master:0} or sometimes its can be {master:1} from been written to the log file I made changes to the following line which didn't work Code:
nRow = g_objNewTab.Screen.CurrentRow strPrompt = g_objNewTab.screen.Get(nRow, _ 0, _ nRow, _ g_objNewTab.Screen.CurrentColumn - 1) strPrompt = Trim(strPrompt) split_strPrompt = Split(strPrompt, " ") For mytokenIndex = 0 To UBound(split_strPrompt) - 1 strPrompt = split_strPrompt(1) Code:
Dim strResult strResult = g_objNewTab.Screen.ReadString(strPrompt) Last edited by emexy; 05-06-2015 at 04:05 PM. |
#72
|
|||
|
|||
Hi emexy,
It looks like you are changing the wrong part of the script. If you make the change to strResult rather than strPrompt, do you get better results? Do your vlans have a particular naming convention that would make them have a string in common? Do they all include "vlan" in the name? |
#73
|
|||
|
|||
The changes to the strResult didn't work.
The vlan names do not follow a particular naming convention, however the position in every line of output is unique.(i.e it is always going be the first word before a space) example of the output is vlanteachers 2178 vlanstudents 2129 vlantest1 1354 storeroom 3678 warehouse 1556 {master:0} hostname> Q2: Is there a way to filter out that last entry {master:0} or sometimes its can be {master:1} from been written to the log file. This always end each command I figured out how to remove the unwanted string before it gets written, I added this line above line 292 Code:
strResult = Replace(strResult, "{master:0}" , " ") Last edited by emexy; 05-06-2015 at 08:09 PM. |
#74
|
|||
|
|||
Hi emexy,
I am glad to hear that you found a way to filter out the unwanted string. You could modify your approach to remove the unwanted string and the blank line. For example: strResult = Replace(strResult, vbcrlf & "{master:0}" , "")To parse the output, you could use something similar to the following: Code:
strResult = Replace(strResult, vbcrlf & "{master:0}" , "") strResult = Replace(strResult, vbcrlf & "{master:1}" , "") strResult = Replace(strResult, vbcrlf & vbcrlf, vbcrlf) strVlanReport = "" ' Create an array of the results that we can iterate over. vLines = Split(strResult, vbcrlf) ' Iterate over the array For Each strLine in vLines ' Find out if the line has a space. If it does capture the location. nPos = Instr(strLine, " ") ' If a space is found, capture the data left of the space. If nPos > 0 Then strVlanReport = strVlanReport & vbcrlf & Left(strLine, nPos - 1) End If Next strResult = strVlanReport As a note, if you are running other commands, you will likely want to only run the code above if the command is sh vlans. |
#75
|
|||
|
|||
Quality!
100% working now with your script Todd. Thanks |
![]() |
Tags |
example script |
Thread Tools | |
Display Modes | Rate This Thread |
|
|