Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-17-2015, 03:29 AM
dimi3 dimi3 is offline
Registered User
 
Join Date: Jun 2015
Posts: 3
Not appending logs

Hello support,

I'm trying to create my first script which will connect to Cisco hosts through jump server. On this hosts some command will be executed and only their outputs want I to capture into log file.

Currently my script create 4 different log files and don't append after I stop the session.log. I have tried to use default logging from pre-configured session and also to create a new file. The result is always the same. After I stop the logging new file is created and not appending.

here are what I see in the log files:
1. logging to jump server
2. logging to the cisco host
3. outputs from commands: !2 testing and !3 testing
4. outputs from command: exit

why file2 is not appending to file1 and same for file4 not appending to file3?

thank you

Code:
#$Language="VBScript"
#$Interface="1.0"


crt.Screen.Synchronous = True

' This script is for connecting to a specific host and performing command.
Sub Main()


' Make sure we are disconnected before attempting a connection
If crt.Session.Connected Then crt.Session.Disconnect
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' Connect to host cacti
crt.Session.Connect  "/S Cacti_test"
' wait for specific string on screen and after it do work on the remote machine.
crt.Screen.WaitForString "$"

'Logging
If crt.Session.Logging Then
	' Turn off logging before setting up our script's logging...
	crt.Session.Log False
End If

'====================================================================
crt.Session.LogUsingSessionOptions

crt.Screen.Send "telnet host" & chr(13)
crt.Screen.WaitForString "sername: "
crt.Screen.Send "user" & chr(13)
crt.Screen.WaitForString "assword: "
crt.Screen.Send "pass**" & chr(13)
crt.Screen.WaitForString "#"

'crt.Session.LogUsingSessionOptions
crt.Session.Log False

' wait for specific string on screen and after it do work on the remote machine.
crt.Screen.Send "!1 testing =====================" & chr(13)
' Waiting for specific string on screen and then exit
crt.Screen.WaitForString "#"


'====================================================================
' Set the name of the log file name 
  '
  Dim logfile
  logfile = "D:\Logs\%Y-%M-%D--%h-%m-%s.%t-%S.txt"	
  crt.Session.LogFileName = logfile

  ' Enable logging
  '
  crt.Session.Log True

crt.Screen.Send "!2 testing =====================" & chr(13)
' Waiting for specific string on screen and then exit
crt.Screen.WaitForString "#"

'crt.Session.Log False
'====================================================================
'crt.Session.Log True, True

crt.Screen.Send "!3 testing =====================" & chr(13)
' Waiting for specific string on screen and then exit
crt.Screen.WaitForString "#"

crt.Session.Log False
'====================================================================
'crt.Session.LogUsingSessionOptions

crt.Screen.Send "!4 testing =====================" & chr(13)
' Waiting for specific string on screen and then exit
crt.Screen.WaitForString "#"

crt.Session.Log True, True

crt.Screen.Send "exit" & chr(13)
crt.Screen.WaitForString "$"

' Disconnect before moving on to the next host
crt.Session.Disconnect
End Sub
Reply With Quote
  #2  
Old 06-17-2015, 10:02 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,015
Hello dimi3,

That is because your log filename is so specific that a unique file is created every time.

Quote:
D:\Logs\%Y-%M-%D--%h-%m-%s.%t-%S.txt"
Since this is date *and* time stamped, the odds you connect in the exact same millisecond so SecureCRT can append the output to the existing file is astronomical.

Maybe just using just a date stamp would work better for you:

D:\Logs\%Y-%M-%D--%S.txt
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 06-19-2015, 09:15 AM
dimi3 dimi3 is offline
Registered User
 
Join Date: Jun 2015
Posts: 3
yeah, that was the issue. Thank you
Reply With Quote
Reply


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 06:30 PM.