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 10-03-2008, 08:43 AM
wcroth wcroth is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
Need to append output to 1 log file

Hi - The attached script will log each session to it's own logfile but I am trying to append all the sessions / output to 1 logfile ex: output.txt. Any assistance is appreciated. Thanks
Attached Files
File Type: txt test5change.txt (3.3 KB, 528 views)
Reply With Quote
  #2  
Old 10-03-2008, 10:03 AM
tnygren's Avatar
tnygren tnygren is offline
Registered User
 
Join Date: May 2005
Posts: 1,408
Hi Wcroth,

It is possible to append the log data to a single log file.

This can be done my modifying the start of the logging. The following will start the logging but append the data to the end of the log file:

crt.Session.Log True, True

Does this help?

Do multiple sessions need to log at the same time?
__________________
Thanks,

Teresa

Teresa Nygren
Reply With Quote
  #3  
Old 10-03-2008, 11:05 AM
wcroth wcroth is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
Perfect, thanks!
Reply With Quote
  #4  
Old 10-03-2008, 11:34 AM
wcroth wcroth is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
What would the pause cmd be after it sends command and see's # sign?
If DeviceType = "IOS" then
crt.Screen.Send "term len 0" & chr(13)
crt.Screen.WaitForStrings "#"
crt.Screen.Send "sho ver | in System image" & chr(13)
crt.Screen.WaitForStrings "#"
WANT A PAUSE RIGHT HERE B4 ITS STARTS NEXT SESSION maybe a 2 or 3 sec pause
End If
Reply With Quote
  #5  
Old 10-03-2008, 11:47 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 132
crt.Sleep <millisec>

i.e.

crt.sleep 2000

Wes
Reply With Quote
  #6  
Old 10-06-2008, 07:08 AM
wcroth wcroth is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
Thanks WesR, new at this. Need help w/ error handling, If a device in my device list is not reachable and I am unable to connect I need the script to continue and also log that in my output file as "Unable to Connect".
Reply With Quote
  #7  
Old 10-06-2008, 08:19 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi wcroth,

I have attached an example script that demonstrates error-handling while connecting in SecureCRT.

Using the information contained therein, are you able to successfully accomplish what it is you are looking to do?
Attached Files
File Type: txt Connect-DetectErrorConnecting.vbs.txt (1.2 KB, 350 views)
Reply With Quote
  #8  
Old 10-20-2008, 10:29 AM
wcroth wcroth is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
Thanks Kevin, having trouble with and where to plug it in my current script and writing it to my output file. I know the funtion will go at the bottom, but not sure where to put the actual error check and how to write it to the ouput file.
Reply With Quote
  #9  
Old 10-20-2008, 10:32 AM
wcroth wcroth is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
attached current script
Attached Files
File Type: txt router_info.txt (3.3 KB, 359 views)
Reply With Quote
  #10  
Old 10-20-2008, 03:26 PM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi wcroth,

The example script I provided demonstrates the ability to use the vbscript 'On Error Resume Next' command to tell the scripting engine to let us (the script itself) handle all errors.

The following is an explanation of how to handle connection errors and log the errors to the SecureCRT log file:
Replace your crt.Session.Connect() calls to actually be calls to the Connect() function.

If the connect is not successful, the example script I provided demonstrates how to structure an if statement to handle the error. The following code is an example of how to log custom data to the SecureCRT log file:

Code:
Dim objFSO, objLogFile
Set objFSO = CreateObject("Scripting.FileSystemObject")

Const ForAppending = 8
Const bStart = True
Const bStop = False

' Retrieve the SecureCRT log file
szLogFile = crt.Session.LogFileName

' Stop logging in SecureCRT briefly so we can write to the log file
crt.Session.Log bStop

' Open the log file
Set objLogFile = objFSO.OpenTextFile(szLogFile, 8)

' Write our custom data
objLogFile.Write "Connection failed with the following error:" & vbcrlf & _
    vbcrlf & Err.Description

' Close the log file so we can resume logging in SecureCRT
objLogFile.Close

' Start logging in SecureCRT
crt.Session.Log bStart, True
Does this information help to handle connection errors and log the errors to the SecureCRT log file?
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 01:14 AM.