|
VMS Help PIPE, Examples *Conan The Librarian |
1.$ PIPE SHOW SYSTEM | SEARCH SYS$INPUT HIB
This example uses the pipeline function to identify all
hibernating processes on the system in one command.
2.$ PIPE RUN TEST | SORT/SPECIFICATION=TEST.SRT SYS$INPUT SYS$OUTPUT -
| DIFF SYS$INPUT TEST.BENCHMARK
This example uses the pipeline function to run a test, sort
the result, and compare the result to the benchmark file in
a single command without generating unnecessary intermediate
files.
3.$ PIPE ( SET DEF WRK$:[WORK] ; RUN REPORT ) | MAIL SYS$INPUT SMITH
This example shows one way a subshell can be specified as a
pipe segment command in a pipeline.
4.$ more :== TYPE/PAGE=SAVE SYS$INPUT
$ PIPE ANA/RMS PAGE.TXT | more
Check RMS File Integrity 26-DEC-2001 16:12:00.06 Page 1
SYS$SYSDEVICE:[TEST]PAGE.TXT;2
FILE HEADER
File Spec: SYS$SYSDEVICE:[TEST]PAGE.TXT;2
File ID: (4135,58220,0)
Owner UIC: [PIPE]
Protection: System: RWED, Owner: RWED, Group: RE, World:
Creation Date: 26-NOV-2001 16:08:50.05
Revision Date: 26-NOV-2001 16:09:09.06, Number: 1
Expiration Date: none specified
Backup Date: none posted
Contiguity Options: none
Performance Options: none
Reliability Options: none
Journaling Enabled: none
RMS FILE ATTRIBUTES
RETURN/SPACE=More, PREV/NEXT=Scroll, INS/REM=Pan, SELECT=80/132, Q=Quit
This example shows the use of the /PAGE qualifier within a
pipeline. The /PAGE function exists in a number of other DCL
commands as well, and can be used similarly in conjunction with
the PIPE command to form other useful tools.
5.$ ! TEE.COM - command procedure to display/log data flowing through
$ ! a pipeline
$ ! Usage: @TEE log-file
$
$ OPEN/WRITE tee_file 'P1'
$ LOOP:
$ READ/END_OF_FILE=EXIT SYS$PIPE LINE
$ WRITE SYS$OUTPUT LINE ! Send it out to next stage of the pipeline
$ WRITE tee_file LINE ! Log output to the log file
$ GOTO LOOP
$ EXIT:
$ CLOSE tee_file
$ EXIT
This is an example of a pipeline DCL application TEE.COM.
The PIPE command to use TEE.COM can be:
$ PIPE SHOW SYSTEM | @TEE showsys.log | SEARCH SYS$INPUT LEF
The command procedure TEE.COM is used to log the data flowing
through the pipeline. It reads in the data from SYS$PIPE
instead of SYS$INPUT.
6.$ CD_WORK :== PIPE SAVE_DIR=F$DIRECTORY() ; SET DEFAULT FOO:[WORK]
$ BACK :== SET DEF 'SAVE_DIR'
$
$ CD_WORK ! Switch to working directory
$ :
$ :
$ BACK ! Switch back to home directory
$ GET_RECORD :== PIPE READ/END_OF_FILE=CLEANUP IN RECORD ; -
F$EDIT(RECORD, "COMPRESS, TRIM")
$
$ OPEN IN EMPLOYEE.DAT
$ LOOP:
$ GET_RECORD
$ :
$ :
$ GOTO LOOP
$
$ CLEAN_UP:
$ :
This example shows two simple uses of multiple commands with
symbol definitions to build useful tools in command procedures.
7.$ PIPE cc foo.c && link foo
If the compilation does not generate any error, the object
file is linked to produce an executable image. If the program
compilation generates an error, the linking step is skipped.
8.$
$ PIPE RUN COLLECT_DATA.EXE || GOTO CLEAN_UP
$ :
$ :
$ EXIT
$
$ CLEAN_UP:
$ :
$ :
Using conditional command execution, it is easy to set up
simple error handling control flow in a command procedure.
If the image COLLECT_DATA fails, control is directed to CLEAN_
UP.
9.$ PIPE COPY LARGE_FILE.DAT REMOTE"user password"::[DESTINATION]*.* &
This PIPE command creates a background process to handle the
copying of the large file.
10$ PIPE (SET DEF [.DATA_DIR] ; BACKUP DATA.SAV/SAV [...]) ; RUN FOO
The subshell command sequence is done in a subprocess. This
means that changing a process-specific characteristic (for
example, the default directory) will not affect the current
process after the subshell is finished. In this example, the
save set is restored in a subdirectory to provide the necessary
data to run the program FOO.
11$ RSH 0 PIPE SH DEC/FI | SH LOG/PR
LNM$PROCESS_TABLE
"SYS$COMMAND" = "_NODE$MPA24:"
"SYS$DISK" = "SYS$SYSDEVICE:"
"SYS$ERROR" = "_BG9930:"
"SYS$INPUT" [super] = "_BG9930:"
"SYS$INPUT" [exec] = "_NODE$MPA24:"
"SYS$OUTPUT" [super] = "_BG9930:"
"SYS$OUTPUT" [exec] = "_BG9930:"
"SYS$PIPE" = "_NODE$MPA24:"
"TT" = "_MPA24:"
This example shows how SYS$PIPE and SYS$OUTPUT might differ.
|
|