#1
|
||||
|
||||
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 | " Code:
objTab.Session.LogUsingSessionOptions Real questions for this thread:
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
|
||||
|
||||
Rhudi,
There isn't any universal documentation along these lines that would apply to all versions of SecureCRT on all platforms. Quote:
Quote:
Quote:
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
|
||||
|
||||
I am sending from an array of router commands.
I must wait for the system prompt before attempting to send each command. |
#4
|
||||
|
||||
Quote:
--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
|
||||
|
||||
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 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
|
||||
|
||||
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|