Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-19-2021, 12:07 PM
Rhudi's Avatar
Rhudi Rhudi is offline
Registered User
 
Join Date: Jul 2013
Location: Greenville, SC
Posts: 95
List of what "objTab.Session.Config.SetOption" can touch?

RTFM is the operable concept here. The real problem, until you know how to search the Manual's TOC or Index, you're kind of lost.

Here is the only example I know...

I know I can go here: 'Session Options', 'Log File', 'Custom log data', 'On each Line'

Only because I found and obscure reference online, I know that relates to this:
Code:
objTab.Session.Config.SetOption "Custom Log Message Each Line", "%h:%m:%s | "
This was especially difficult to understand, as I only found by accident that this will not do anything as you expect, unless you use:
Code:
objTab.Session.LogUsingSessionOptions
How was I to know that?

Real questions for this thread:
  1. Is there a way to to affect settings in 'Global' and 'Default' using a ".SetOption" command?
  2. What are the Options I can set, and which ones need a 'Trigger' to make them happen?
    (Is there a list of what "objTab.Session.Config.SetOption" is related to and can touch?)

Ultimately, I need to be able to control Session Settings to keep the environment stable. I have VBS that works perfectly for me, but on a coworker's system, he uses "Send delay options", "Line send delay" set to 1000ms. My VB doesn't work on his system. Is the easiest thing is to be able to set the option? The actual thing this seems to break is 'WaitForString'. If his 'Delay' is higher than my Timeout, it dies.
  #2  
Old 01-19-2021, 03:42 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,086
Rhudi,

There isn't any universal documentation along these lines that would apply to all versions of SecureCRT on all platforms.

Quote:
Originally Posted by Rhudi View Post
Is there a way to to affect settings in 'Global' and 'Default' using a ".SetOption" command?
Yes, but only SecureCRT versions 8.7 and newer support any API for interacting with Global Options.

Quote:
Originally Posted by Rhudi View Post
What are the Options I can set, and which ones need a 'Trigger' to make them happen?
(Is there a list of what "objTab.Session.Config.SetOption" is related to and can touch?)
As mentioned earlier, there isn't any universal documentation about options that can be set which would apply to all versions of SecureCRT on all platforms. If you have a specific question about a specific option, please provide the specifics and we'll see if we can provide some info/clarification.

Quote:
Originally Posted by Rhudi View Post
Ultimately, I need to be able to control Session Settings to keep the environment stable. I have VBS that works perfectly for me, but on a coworker's system, he uses "Send delay options", "Line send delay" set to 1000ms. My VB doesn't work on his system. Is the easiest thing is to be able to set the option? The actual thing this seems to break is 'WaitForString'. If his 'Delay' is higher than my Timeout, it dies.
Performance and capabilities of different networking and hardware environments introduce variation which complicates the use of timeouts or "pause" approaches -- as seen when you make assumptions and decisions that end up working great for you in your environment but not for others in their environment.

Why do you have any Timeouts at all? If a specific text component must appear before you move on with subsequent steps in your script, there shouldn't be any time outs -- the script code shouldn't move on unless you know for sure it's "safe" to proceed.

In terms of Line Send Delay, it's a setting which governs how long SecureCRT will wait after sending a line of data before the next line will be sent. The setting helps to control how fast SecureCRT will send data to a connected device -- a device that may not implement flow control (it may not indicate its input buffers are full and it cannot handle any more data, silently -- and frustratingly -- dropping any and all data received until its input buffers have been processed, freeing up room for more data to be received and processed). If a device doesn't implement any flow control and silently drops data that SecureCRT sends to it, one approach to fix things can be to slow down the rate at which SecureCRT sends data to the remote device. Hence, the Line Send delay. The use of crt.Sleep() calls to introduce arbitrary delays is not a robust solution. The use of crt.Screen.WaitForString() passing in a timeout parameter -- that's also not a robust solution. Instead the use of WaitForString() calls without any timeout values should be used with crt.Screen.Synchronous set to True to ensure that the remote device has received what you sent and is ready to receive more and that calls to WaitForString(), ReadString(), etc. will be able to apply to data received but not yet displayed to the Screen.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
  #3  
Old 01-19-2021, 06:03 PM
Rhudi's Avatar
Rhudi Rhudi is offline
Registered User
 
Join Date: Jul 2013
Location: Greenville, SC
Posts: 95
I am sending from an array of router commands.
I must wait for the system prompt before attempting to send each command.
  #4  
Old 01-20-2021, 07:35 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,086
Quote:
Originally Posted by Rhudi View Post
I am sending from an array of router commands.
I must wait for the system prompt before attempting to send each command.
Based on the simplicity of the tasks you mention, it doesn't seem like your script would need to set session options in general.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
  #5  
Old 01-21-2021, 09:05 AM
Rhudi's Avatar
Rhudi Rhudi is offline
Registered User
 
Join Date: Jul 2013
Location: Greenville, SC
Posts: 95
It is possible that I'm making my script over-complicated. However, what I am able to do...

From Excel, I have a sheet that will let me select a folder that has any number of router data files. These files contain more than only "show config" type commands. I have several "information gathering" commands... like: "show bgp summay", "show interface descriptions", and others.

These show commands will be different, based on the type of router (Cisco, Juniper, etc).

Originally, I was using the Copy Buffer to share data and commands. That quickly showed itself has highly unreliable.

Unfortunately, about 80% of what I'm doing is proprietary.

Generally, my Excel code will let me specify a folder, and can load an array of cells with a list of files. (Due to demand, I've had to keep upping the limit on number of files to over 100.) From that list, the Excel app creates a Temporary file, with that list pared down to the actual device name. A shell command within Excel starts SecureCRT with an AdHoc session that is provided with the full path to that file. SecureCRT has a Do/Loop that will read every line in that file. As well, this initial 'start' uses an app-specific environment variable for SecureCRT to let Excel know what is happening.

(I am about to create an application to let Excel send a router command through a SecureCRT session that is using a VB Loop. Each 'side' will use an environment variable to let each half of this thing to communicate when commands are sent and output is ready.)

The initial JumpHost I have to use will require a password that may or may not require an additional secure token as part of the password. Once the session is going, as it loops through my input data file, it determines which router type is being accessed. Within the SecureCRT VB are 'command array' entries that are different, depending on the router type. At this point, I use the SecureCRT logging mechanism to capture the output to put the log file where Excel specifies. As well, each of the array commands have a character that turns on/off a "per line" preamble to the lines in the log file for the running command.

The best part of this is the surprise ability for this to run multiple sessions in parallel, each pulling data simultaneously).

I just used this yesterday to pull 103 configs. All of the logons and commands done manually would have taken a day or more to complete. This VB code pulled them all in 80 minutes, with no further interaction after it started.

The road block I have is minor "user preferences" for other people trying to use my app.

Since I am using an AdHoc session, I hope to set many of these user preferences so the VB will be able to run within a level environment.

---

So, having said all that...
What is the internal string for '.SetOptions' to be able to set 'Line send delay'?
(It is unfortunate that there is no list of which options can be set this way.)

I can provide this snippet:
Code:
' Assume the device prompt is stable (There is a short 'Sleep' and 'objTab.Screen.WaitForCursor' before we get here)
strPrompt = Trim(objTab.Screen.Get(objTab.Screen.CurrentRow, 1, objTab.Screen.CurrentRow, objTab.Screen.CurrentColumn - 1))
'
For Each strCommand in arrCommandLines
    '
    Select Case Left(strCommand, 1) ' Toggle Logging to set/clear the comment prefix
        Case ">" ' Add the per-line log prefix
            strCommand = Mid(strCommand, 2)
            crt.Session.Log  False
            objTab.Session.Config.SetOption "Custom Log Message Each Line", strBannerPre & " "
            objTab.Session.LogUsingSessionOptions
        Case Else ' No per-line prefix
            crt.Session.Log  False
            crt.Session.Log  True, True
    End Select
    '
    objTab.Screen.Send strCommand & vbCr  ' Send command to the device.
    objTab.Screen.WaitForString strPrompt ' Wait for the prompt.
    crt.Sleep (125)
Next
This is the one 'WaitForString' that absolutely can not have a timeout. Some of these device commands can take a very long time to return results. I just have to be aware that if my connection hangs during this, I have to eventually assume it died and manually intervene. Which is a horrible sloppy way to ever write code.

One of the practices that I believe in is around the speed improvement of 'Select Case' compared to the 'If..Then...ElseIf...EndIf' structure.

I have all kinds of little tricks that keep the code simple. I could spend days sharing individual tricks.
  #6  
Old 01-21-2021, 04:51 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,086
Quote:
Originally Posted by Rhudi View Post
...for other people trying to use my app.
Rhudi,

Please send email to support@vandyke.com referencing forum thread #14398.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 07:53 AM.