This is a discussion on logging nt command file console output. - Windows NT ; We use CA-7 Agent to run NT command files (.cmd) in unattended batch mode where nobody sees the console output. We use to track the progress of the command files by using redirect operators on each line of the command ...
We use CA-7 Agent to run NT command files (.cmd) in unattended batch
mode where nobody sees the console output.
We use to track the progress of the command files by using redirect
operators on each line of the command file.
Instead of changing each line of the command file, I have found it
easier to shell the command file from another command file shellnt.cmd
which redirect both SDTOUT - 1 and SDTERR -2 to a loggfile specified by
the second parameter.
REM - SHELL AN NT BATCH C0MMAND FILE (%1) AND THEN RETURN WHEN COMPLETE
REM - REM LOG CONSOLE OUTPUT TO log specified by %2
REM - REDIRECT STANDARD ERROR (2) INTO STANDARD OUTPUT (1) the log
REM - EX SHELLNT e:\ii\agpp\batch\AGPPL010.cmd
e:\ii\agpp\agppl010.log P -
rem WHICH WILL RUN
AGPPL010.CMD WITH PARM P
REM AND LOG THE OUTPUT
REM - WHERE %1 IS COMMAND FILE (JOBNAME) you want to run
REM %2 is a log file
REM - %3 %4 %5 ARE Optional PARAMETERS passed to THE BATCH
rem this log file is used to track shellnt processing - the
applicaiton cmd file uses the file in %2
echo 1 - starting job %1 >%LOGFN%
echo 2- log %2 with: >>%LOGFN%
echo 3- %3 >>%LOGFN%
echo 4- %4 >>%LOGFN%
echo 5- %5 >>%LOGFN%
rem shell the application command file %1 and log to %2
rem note STDERR 2 is redirected to STDOUT 1 with 2>&1
CMD /C%1 %3 %4 %5 >%2 2>&1
echo job %1 Done >>%LOGFN%