Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2016, 10:48 PM
cgkas cgkas is offline
Registered User
 
Join Date: Nov 2016
Posts: 2
Store in different logfiles for each array element vbscript

Hello to all in Van Dyke forum,

I'm new with scripting in CRT, please help.

I want to run a script that sends some command taking input from an array. For each element of the array I want the respective print to be stored in a different log file.

The script I made so far is below but doesn't work. It seems that only stores the print of last command sent.

How would be the correct way to do it please?

Code:
#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

Sub Main
  arr = "1,2,3"
  a = Split(arr, ",")

  For i = LBound(a) To UBound(a)
    crt.Session.Log False 'Turn off log session
    crt.Session.LogFileName = "C:\Users\Path\MyLogfile No." & a(i) & ".log"  'Define log file name
    crt.Session.LogUsingSessionOptions 'Turn on log session

    crt.Screen.Send "some command" & a(i) & ";" & Chr(13)  'Some command sent to each arr element, this part works fine
  Next

  crt.Session.Log False

  'Restore the default log file     
  crt.Session.LogFileName = "C:\Users\myuser\Documents\default.log"
End Sub
Thanks in advance.

Regards
Reply With Quote
  #2  
Old 12-02-2016, 08:17 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hi cgkas,

Perhaps you need to add a WaitForString() after you send the command(s) because it could be exiting the For Loop and turning off logging before the command completes.

Code:
    crt.Screen.Send "some command" & a(i) & ";" & Chr(13)  'Some command sent to each arr element, this part works fine
    crt.Screen.WaitForString "shell_prompt"
  Next
That worked for me, resulting in three log files with the output from a command in each.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 12-02-2016, 10:05 AM
cgkas cgkas is offline
Registered User
 
Join Date: Nov 2016
Posts: 2
Thumbs up

Hello dear Brenda,

Excellent! Thanks for your fast response.

With your advice it works pretty fine now.

Best regards
Reply With Quote
  #4  
Old 12-02-2016, 10:32 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hi cgkas,

Thanks for posting an update.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply

Tags
automation , log file , vbscript

Thread Tools
Display Modes

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 02:19 PM.