#1
|
|||
|
|||
Secure CRT not logging to file via script
Hi,
Have a very basic problem when trying to log output of a router command to a log file from script. The Logfile gets created but is always empty. The script is pasted below: -------------------------------------------------------- # $language = "VBScript" # $interface = "1.0" Sub Main crt.Screen.Synchronous = True crt.Session.Connect "/TELNET a.b.c.d 23" crt.Screen.WaitForString "sername:" crt.Screen.Send "xxx" & vbCr crt.Screen.WaitForString "assword:" crt.Screen.Send "xyz" & vbCr crt.session.logfilename="blahblah.log" crt.session.log TRUE crt.Screen.Send "show ip int br" & vbCr crt.Screen.Synchronous = False crt.session.log FALSE ----------------------------------------------------- End Sub |
#2
|
||||
|
||||
When Synchronous is set to True, SecureCRT does not display any data to the terminal screen until you call WaitFor*() or ReadString().
What's happening in your case is you've told SecureCRT's script engine to send a command, and immediately after sending that command, you've told SecureCRT's script engine to turn off Synchronous and then turn off logging. Since you haven't waited for the data to arrive (and be displayed to the terminal screen), there's nothing (or perhaps very little, if anything) that gets logged because you told SecureCRT to stop logging. This happens in script code so quickly that either no data has even arrived yet from the device, or it has but since Synchronous is still set to True when it does arrive, and none of it has been displayed to the screen (and therefore isn't available to be logged). You can solve the problem by adding a crt.Screen.WaitForString("Put_Your_Shell_Prompt_Here") line right before you turn off Synchronous. If you're having trouble figuring out how to automatically determine what your shell prompt is on the remote device, either a) try to use something that's unique enough that it wouldn't show up in the command output, but the same on all your different devices, or b) read about heuristically determining the shell prompt as described in the SecureCRT Scripting Guide (see example code on pages 92 and 114 as a good starting point). --Jake
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
![]() |
Tags |
logfile , logging , output , router , scripting |
Thread Tools | |
Display Modes | Rate This Thread |
|
|