Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #61  
Old 04-24-2015, 10:56 AM
Damon Damon is offline
Registered User
 
Join Date: Apr 2015
Posts: 11
Quote:
Originally Posted by rtb View Post
Hi All,

We are working on this issue via email. If we can find out what is wrong in this specific case and environment, I will post here.
Issue has been resolved. Thanks for your fast and responsive email support!!
Reply With Quote
  #62  
Old 04-24-2015, 11:07 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
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.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #63  
Old 05-05-2015, 06:40 PM
emexy emexy is offline
Registered User
 
Join Date: May 2015
Posts: 7
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
Reply With Quote
  #64  
Old 05-06-2015, 08:01 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
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)?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730

Last edited by rtb; 05-06-2015 at 09:15 AM. Reason: editing for more accuracy and completeness
Reply With Quote
  #65  
Old 05-06-2015, 10:51 AM
emexy emexy is offline
Registered User
 
Join Date: May 2015
Posts: 7
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
Reply With Quote
  #66  
Old 05-06-2015, 11:09 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
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.).

Please redact sensitive information that would not be appropriate for a public forum prior to posting the requested information.

If there is sensitive information that must be conveyed in order to provide a complete picture of the scenario you're facing, please let us know and we will set up a secure upload mechanism that can be used.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #67  
Old 05-06-2015, 11:16 AM
emexy emexy is offline
Registered User
 
Join Date: May 2015
Posts: 7
This is what is shows

Firewall Name /SSH2 /ACCEPTHOSTKEYS /L myusername /AUTH
password,keyboard-interactive /PASSWORD mypassword mydevicename
Reply With Quote
  #68  
Old 05-06-2015, 11:30 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
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 "
' g_strFirewall = ""
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?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730

Last edited by rtb; 05-06-2015 at 12:01 PM.
Reply With Quote
  #69  
Old 05-06-2015, 11:54 AM
emexy emexy is offline
Registered User
 
Join Date: May 2015
Posts: 7
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
Reply With Quote
  #70  
Old 05-06-2015, 12:37 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
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.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #71  
Old 05-06-2015, 03:58 PM
emexy emexy is offline
Registered User
 
Join Date: May 2015
Posts: 7
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)
before it gets called here
Code:
Dim strResult
                   
                    strResult = g_objNewTab.Screen.ReadString(strPrompt)

Last edited by emexy; 05-06-2015 at 04:05 PM.
Reply With Quote
  #72  
Old 05-06-2015, 04:53 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
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?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #73  
Old 05-06-2015, 05:51 PM
emexy emexy is offline
Registered User
 
Join Date: May 2015
Posts: 7
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.
Reply With Quote
  #74  
Old 05-07-2015, 11:37 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
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}" , "")
strResult = Replace(strResult, vbcrlf & "{master:1}" , "")
strResult = Replace(strResult, vbcrlf & vbcrlf, vbcrlf)
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
Does this help you accomplish your goal?

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.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #75  
Old 05-07-2015, 12:08 PM
emexy emexy is offline
Registered User
 
Join Date: May 2015
Posts: 7
Quality!
100% working now with your script Todd.
Thanks
Reply With Quote
Reply

Tags
example script

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:18 AM.