Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Old 06-04-2016, 12:11 AM
mehbooburrehman mehbooburrehman is offline
Registered User
Join Date: Jun 2016
Posts: 2
Secure CRT not logging to file via script


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.log TRUE

crt.Screen.Send "show ip int br" & vbCr

crt.Screen.Synchronous = False
crt.session.log FALSE


End Sub
Reply With Quote
Old 06-04-2016, 10:17 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
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 Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote

logfile , logging , output , router , scripting

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 05:04 AM.