howto:capture_dcl_command_output_in_a_file_and_on-screen_simultaneously

How To Capture DCL Command Output to a Text File and On-Screen Simultaneously

Ever need to both review some DCL command output on-screen and capture it to a file at the same time?

This happens more often than you might guess. For example, you may need to capture some fast-changing VMS state information (like a process in RWAST state), but doing the same command twice-in-a-row may not show the same overall system state (things can change fast).

Here's how – Use a tee command file.

$ ! TEE.COM -- split input from SYS$PIPE to SYS$OUTPUT             'F$VERIFY(0)'
$ !            and another output (file)
$ !
$ !  Usage: @TEE teefile
$ !
$ !  Setup: $ TEE == "@com:tee" (in user's LOGIN.COM file)
$ !
$ !  Designed for use in VMS pipes, relies on SYS$PIPE as input-stream:
$ !
$ !    $ PIPE show system | TEE sys$scratch:capture.lis | search sys$pipe RWAST
$ !      ! captures all SHOW SYSTEM output...
$ !  or:
$ !    $ PIPE show system | search sys$pipe RWAST | TEE sys$scratch:capture.lis
$ !      ! captures only SEARCH output matching the requested state...
$ !
$ SET NOON
$ OPEN /WRITE /ERROR=Oops teefile 'P1'
$Loop:
$ READ /END_OF_FILE=Done sys$pipe line
$ WRITE sys$output line
$ WRITE teefile    line
$ GOTO Loop
$Done:
$ CLOSE /NOLOG teefile
$ EXIT %X01  !'F$VERIFY(0)'
$Oops:
$ WRITE sys$error "%TEE-E-OPENERR, cannot open ''P1'"
$ EXIT %X2C  !'F$VERIFY(0)'
$ !

This DCL script is designed to work in a DCL PIPE command construct, the only context where the temporary logical name SYS$PIPE exists (this is created/deleted by the PIPE command itself).

The script reads each line (text-data record) from the SYS$PIPE data-stream (which communicates data from one command to the next command in the pipe chain), and then (re)writes each line out to SYS$OUTPUT (usually, your terminal screen, but this can be redirected too) and to a file which is named as this script's P1 parameter.

Set this up in your own LOGIN.COM file with this command-symbol definition:

$ TEE == "@com:tee"

You can substitute your own subdirectory logical name for the com logical name shown above.

The two examples in the script show just how easy this is to do – Note however that the placement of the TEE command-symbol itself in the pipe chain does matter to what is captured into the output file itself.

Examples:

$ PIPE show system | TEE sys$scratch:capture.lis | search sys$pipe RWAST

…captures all of the SHOW SYSTEM command's output.

or:

$ PIPE show system | search sys$pipe RWAST | TEE sys$scratch:capture.lis

…captures only SEARCH command's output matching the requested state.

Have fun… How many ways or scenarios can you discover where this is useful?

howto/capture_dcl_command_output_in_a_file_and_on-screen_simultaneously.txt · Last modified: 2018/09/07 22:48 by lricker