#1
|
|||
|
|||
Logging not capturing all commands
Hello,
I am using SecureCRT Version 7.0.3 (x64 build 480) for Windows 7. I have a script that runs in multiple tabs open in one window. It's purpose is to determine the device it is logged into, and then send a series of commands to the device based upon that information. The script is to then capture the output of the commands to a text file saved locally on my C:\drive. The problem I am encountering is that the last few commands on a few devices will not be captured if I turn of logging immediately afterwards. If I do not turn off logging (by commenting out the line just below "STOP LOGGING") then the data is captured, however the logging stays on in that tab, which I do not want to occur. I want to turn on logging, save the output and turn it off. This If statement falls in a for loop that runs on every tab in the window following a series of checks. If I need to post the entire script, please let me know. Any help is appreciated! Thanks! ' JUNIPER PRECHECKS BELOW ***************************************** If devicemx80 = 1 then 'START LOGGING If PRECHECK = vbYes Then crt.Session.Log False objCurrentTab.Session.LogFileName = "C:\Checks\" & TID & "\PRE-%S.log" objCurrentTab.Session.Log True Else crt.Session.Log False objCurrentTab.Session.LogFileName = "C:\Checks\" & TID & "\POST-%S.log" objCurrentTab.Session.Log True End If 'SEND COMMANDS objCurrentTab.Screen.Send "show interface description" & chr(13) objCurrentTab.Screen.WaitForString "> " objCurrentTab.Screen.Send "show configuration interfaces xe-0/0/2" & chr(124) & " match address " & chr(13) objCurrentTab.Screen.WaitForString "> " objCurrentTab.Screen.Send "show configuration interfaces xe-0/0/3 " & chr(124) & " match address " & chr(13) objCurrentTab.Screen.WaitForString "> " objCurrentTab.Screen.Send "show interface diagnostics optics " & chr(13) objCurrentTab.Screen.Send " " & chr(13) objCurrentTab.Screen.Send " " & chr(13) objCurrentTab.Screen.WaitForString "> " objCurrentTab.Screen.Send "show ospf neighbor " & chr(13) objCurrentTab.Screen.WaitForString "> " objCurrentTab.Screen.Send "show l2circuit connections" & chr(13) objCurrentTab.Screen.WaitForString "> " 'STOP LOGGING objCurrentTab.Session.Log False End If |
#2
|
|||
|
|||
Hi wulfsburg,
We have seen this issue in the past, and it is typically the result of the script being out of sync. You have at least one place in your script where you use Send() three times in a row, putting the script out of sync. To ensure that all data is logged, you should use a WaitForString() call after each Send() call. Does this help to resolve the issue? |
#3
|
|||
|
|||
No, this does not fix my issue. As the tab will shift (for lack of a better term) back , and it will still crop the log output. I have tried modifying the script in a number of ways, including the appropriate amount of screen.waitforstring commands as well as removing the extra sends. Still, I have no luck. I have also tried to insert sleeps with the crt.sleep command, but it doesn't have any affect.
In fact, it seems almost as if it freezes the whole tab. Have any other suggestions? |
#4
|
|||
|
|||
Hi wulfsburg,
Thanks for the update. It is possible that the synchronization issue is occurring prior to the snippet of code you included. I find that the best way to troubleshoot these types of issues is to take the snippet of code and create a separate script from it. Run that script and see if it works. If it doesn't, then we have something solid to test. If it does work, then we know that the problem exists somewhere else in the larger script. Would you create a script out of the snippet of code and test it? Please ensure that you have an equal number of pairs of Send() and WaitForString() calls. |
#5
|
|||
|
|||
I'm having the same problem (but my script is a little simplier).
# $language = "VBScript" # $interface = "1.0" Sub Main crt.Screen.Synchronous = True crt.Screen.Send vbCr crt.Screen.WaitForString "#" Dim logfile logfile = "C:\FTP_ROOT\CONFIGS\%S_%H__%M-%D-%Y-%hh.%mm.config.txt" crt.Session.LogFileName = logfile crt.Session.Log True crt.Screen.Send "term len 0" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== CLOCK/TIME ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "show clock" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== CONFIGURATION ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "show run" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== CHECK VERSION INFO ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "show version" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "dir /all" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== HARDWARE LIST ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "show inventory" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== VIEW ROUTING ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "show ip route" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "show run | include ^ip route" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== VIEW INTERFACE STATISTICS ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "sh ip interface brief" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "sh interfaces counters errors" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "sh interfaces accounting" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== CHECK RESOURCES ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "show proc cpu history | i [0-9]" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "sh proc cpu | e 0.00% 0.00% 0.00%" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "sh processes memory sorted | e 0 0 0" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== VIEW ACCESS LIST HIT COUNTS ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "sh access-list | i matches" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== VIEW THE LOG ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "show log" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send " !=============== LIST VPN CONNECTIONS ===============@ " & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "sh crypto isa sa" & vbCr crt.Screen.WaitForString "#" crt.Screen.Send "term len 40" & vbCr crt.Screen.WaitForString "#" crt.Session.Log False crt.Screen.Send vbCr 'crt.Session.Disconnect End Sub The logging stops at different places. Any ideas? Thanks. |
#6
|
|||
|
|||
Hi collinclark,
I am sorry to hear about the issue. What is the version of SecureCRT that you are using? What operating system are you using? |
#7
|
|||
|
|||
Hi Todd-
I'm running version 7.2.4 (x64 build 524) on Windows 7 |
#8
|
|||
|
|||
Hi collinclark,
Thanks for the information. What are points in the script where the logging stops? Does logging stop at a different point each time? If you don't turn off logging at the end of the script, do you get the complete output? When you send the command that looks like a comment (begins with "!===..."), does the remote device return a prompt? |
![]() |
Tags |
log , logging |
Thread Tools | |
Display Modes | Rate This Thread |
|
|