Re: Can CLP output be timestamped? Yes this it possible.
The most convinient way to do this (for me) is
using the pipe symbol ( | ).
You just run the script from cmdline and redirect (pipe)
its output to some program like tee, etc...
If you running windows you can use my output filter script (.vbs):
save it as .vbs file
'================================================= =========================================
'= outputfilter.vbs
'= special script to capture output from db2 command processor.
'= it can be used as a general output filter (with any console
programs)
'= USAGE (in .cmd file):
'=
'= %comspec% /c script.cmd 2>&1 ^| cscript //nologo outputfilter.vbs
/logfile:script.log
'= output will be echoed to screen and (optionally)
'= saved in script%ISODATE%.log
'================================================= =========================================
Option Explicit
Dim WshShell, StdIn, StdOut, str, outf, outfilename, fso
Set WshShell = WScript.CreateObject("WScript.Shell")
'Set sv-se locale for ISO date/time formatting, example: 2005-03-23
09:13:37
SetLocale "sv-se"
Set StdIn = WScript.StdIn
Set StdOut = WScript.StdOut
set fso = CreateObject("Scripting.FileSystemObject")
outfilename = Cstr(wscript.arguments.named("logfile"))
if len(outfilename)>0 then
set outf = fso.CreateTextFile(outfilename)
else
set outf = nothing
end if
On error resume next
Do While Not StdIn.AtEndOfStream
'replace is needed to remove vbCr symbol
str = Replace(StdIn.ReadLine,vbCr,vbNullstring)
Echo str
Loop
Sub Echo(sMessage)
Dim sMsg
sMsg = Date & " " & Time & " " & sMessage
stdout.writeline sMsg
CheckError "Write to StdOut"
if not outf is nothing then
outf.writeline sMsg
CheckError "Write to output file"
end if
End Sub
Sub CheckError(sMessage)
Dim errNum,errDesc,errSource, errMessage
if err.number<>0 then
errNum = err.Number
errDesc = err.description
errSource = err.source
errMessage = "Error occured. " & sMessage & _
"#" & errNum & "(0x" & errnum & "), " & errDesc & _
", source " & errSource
on error goto 0
WshShell.LogEvent 1,errMessage
Wscript.echo errMessage
end if
End Sub |