$!  Here is the latest regular distribution version of PIPE.
$!
$!  At this time, there is one know bug -- well, it isn't a feature :-). The
$!redirection operators, '<' and '>', which are normally followed by a
$!filespec of some sort (eg: ">WORK.LIS"), must _not_ have a space between
$!themselves and the filespec, or redirection does not occur.
$!
$!  A new version of PIPE, featuring relaxed parsing rules, another
$!redirection operator, a number of new filters, and miscellaneous bug fixes,
$!is expected to be released shortly.  An announcement will be made on
$!info-vax at that time.
$!
$!  Subscribers to the Info-Pipe mailing list are informed directly of new
$!developments.  For this and related news, such as beta releases, the latest
$!neat filters, etc., subscribe to the mailing list by sending a request to
$!<Info-Pipe-Request@noah.arc.ab.ca>.
$!
$!
$!==================
$!
$! ------------------ CUT HERE -----------------------
$!
$! This archive created by VMS_SHARE Version 7.1-001  26-JUN-1989
$!   On  3-AUG-1989 13:09:45.82   By user KENW 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. AAAREADME.TXT;2
$!       2. AAARELEASE.NOTES;2
$!       3. AAASYNOPSIS.TXT;1
$!       4. ALLDUPS.COM;1
$!       5. COMBINE.COM;1
$!       6. COUNT.COM;1
$!       7. DCL.COM;1
$!       8. DUPS.BAS;1
$!       9. DUPS.COM;1
$!      10. ECHO.COM;1
$!      11. EDIT.COM;1
$!      12. ELEMENT.COM;1
$!      13. EXTRACT.COM;1
$!      14. FIL2DIR.COM;14
$!      15. ITEM.COM;1
$!      16. LOCAL_COPIES.COM;1
$!      17. LOCAL_COPIES.DAT;1
$!      18. NOCTRL.C;1
$!      19. NODUPS.COM;1
$!      20. PIPE.COM;102
$!      21. PIPE.HLP;5
$!      22. PIPE_LOGIN.COM;1
$!      23. PIPE_MESSAGE.LIS;1
$!      24. PURGABLE.COM;1
$!      25. SKIP.COM;1
$!      26. SQUISH6.TEC;3
$!      27. SQUISH8.TEC;9
$!      28. STEM.BAS;1
$!      29. STEM.C;1
$!      30. STEM.COM;1
$!      31. STEMS.C;1
$!      32. SUBSTITUTE.COM;2
$!      33. TABIFY.TEC;1
$!      34. TEE.COM;1
$!      35. TIME.COM;1
$!      36. TIMER.COM;12
$!      37. TOTAL.COM;1
$!      38. WIDE.BAS;1
$!
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ if f$getsyi("version") .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete/nolog 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);x:=
ERASE_CHARACTER(1);IF g = 0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x=
"V" THEN APPEND_LINE;MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;
IF x="+" THEN g:=1;ERASE_LINE;ENDIF;ELSE IF x="-" THEN g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
XContents
X========
X
XThe PIPE collection includes:
X
XPIPE    Allows combining DCL commands to operate data
X        eg: pipe SHOW LOGICALS * `124grep TT,TX `124srt >lp:
X`009$! shows only logicals pointing directly to TT and TX devices
X`009without worrying about temporary intermediate files.
X
X`009PIPE provides wildcard filespecs for any command, eg:
X`009  $ pipe dir *.FOR `124 +edit`032
X`009edits every .FOR file.  The '+' switches the mode to 'execute with`032
X`009data as args' from the default 'execute with data as input'.
X
X`009PIPE allows multiple commands to be executed sequentially, as in:
X`009  $ pipe show users > OPA0: ;sho sys >OPA0:
X
X`009PIPE allows redirection of output for programs which don't normally`032
X`009allow this, eg:`032
X`009  $ pipe auth sho brief * >lp:
X
X`009PIPE allows more selective outputs from programs, eg:
X`009  $ p show system `124grep acp,symb
X`009  $! show only ACPs and SYMBIONTs
X
XMisc. Filters
X        These are programs designed to work with PIPE.  NOTE: Compiled`032
X`009programs need no special treatment. Just compile as appropriate and`032
X`009link, both without any special options.`032
X
XSUBSTITUTE
X        Uses PIPE and EDT to do simple search/substutite on many files
X        from a command line
X
XPURGABLE
X        Displays purgable files in any directory/filespec.  Essentially`032
X`009equivalent to what DIR/EXC=; would do if it worked.
X
X
X
XInstallation
X============
X
X  Note: It is assumed that you will unpack these files into an empty
Xsubdirectory, into which you have SET DEFAULT.
X
X  Once you have done that, enter
X
X$ @PIPE_LOGIN.COM
X
Xwhich sets up the PIPE logical and symbol, plus a couple of others which`032
Xare handy but not essential.  This command file should be part of the standa
Vrd`032
Xlogin sequence.  Please note that, since PIPE_LOGIN.COM assumes that its`032
Xlocation is that of the PIPE package, it must be kept with the other files.
X
X
XSoap Box
X========
X
X  In sharing PIPE, my hope is that others will find it sufficiently useful t
Vhat
Xthey will want to improve it, and that they will then share those improvemen
Vts
Xwith myself and others. The best tools seem to grow this way.
X
X/kenw
X
XKen Wallewein                                                     A L B E R
V T A
Xkenw@noah.arc.cdn                                               R E S E A R
V C H
X(403)297-2660                                                     C O U N C
V I L
$ CALL UNPACK AAAREADME.TXT;2 554699643
$ create/nolog 'f'
XThis is a preliminary release of PIPE V3.7 -- "preliminary" because I still
Xintend to clean up the documentation a bit.  The code hasn't changed for a
Xcouple of months, and no immediate changes are planned.
X
X/kenw
$ CALL UNPACK AAARELEASE.NOTES;2 2019234913
$ create/nolog 'f'
X$ P*IPE `091 <fromfile`093 `091 +`093`091command...`093 `091""`093`091args`0
V93`091""`093 `091&line`093 `091 >tofile`093 `091 `124 ...`093
X`009`091 ; ...`093
X
XCOMBINE
X    Combine groups of sequential lines of input into one output record
X
XCOUNT
X    Counts number of lines/records
X
XDI*RECTORY filespec
X    Single-column filespec-only directory to provide lists of filenames
X
XDUPS start length
X    Finds duplicate entries in the specified portion of the line. Input _mus
Vt_`032
X    be in same sorted order.
X
XECHO
X    Sort of like TEE SYS$COMMAND.
X
XEDIT edit_options
X    Performs a DCL F$EDIT (eg: UPCASE,TRIM) on each line of text
X
XELEMENT element_number `091...`093
X    Performs a DCL F$ELEMENT(n," ",line) on each line of input, where
X    the first element is 0, and " " represents any combination of spaces
X    and tabs`032
X
XEXTRACT offset length `091... ...`093
X    Performs a DCL F$EXTRACT(P1,P2,line) on each line of input
X
XFIND filespec search_spec
X    Finds files containing given search arguments. Returns filespec only, fo
Vr`032
X    further action, eg: pipe find auditer `124 +edit
X
XGREP search_spec
X    Pass only entries containing given text.  Supports all SEARCH options.`0
V32
X    Exactly equivalent to SEARCH SYS$INPUT
X
XITEM _text_ `091...`093
X    Element following element containing _text_.
X
XLOCAL_COPIES
X    update local copies of files as needed, according to input parameters.
X    Could be modified to be a MAKE.
X
XJUSTIFY (Not currently inplemented)
X    Uses context to align data into columns (eg: for sorting or totaling)
X
XMORE
X    Exactly equivalent quivalent to TYPE/PAGE SYS$INPUT
X
XNOCTRL
X    Filters out control characters.
X
XNODUPS
X     Everything BUT duplicates (see INIQ).  Input _must_ be in same sorted
X     order.`032
X
XPIPE
X    See top line, AAAREADME.TXT, PIPE.HLP
X
XSKIP number_of_lines
X    Skips the first number_of_lines lines (eg: headers) in the input
X
XTEE filespec
X    Writes a copy of the input to the specified file. Defaults to SYS$COMMAN
VD
X
XTOTAL start-column length `091... ...(I think)`093
X    Total value of all entries in given columns
X
XUNIQ
X    Everything BUT duplicates (See NODUPS). Input _must_ be in same sorted`0
V32
X    order.
X
XWIDE
X    Prints lists in wide format
X
XHandy commands:
X $ gs :== 'pipe show system `124grep`032
X $ e0 :== `124element 0
X $ gs word11 'e0`009! note that the "'" is necessary for inside symbols
X See AAAREADME.TXT for others
$ CALL UNPACK AAASYNOPSIS.TXT;1 1580210685
$ create/nolog 'f'
X!alldups.com - pipe command to find all duplicate filenames`032
XPIPE "DIR ALL" `124 "JUST `093 30 . 40" `124 SRT `124 "DUPS 31 13"
$ CALL UNPACK ALLDUPS.COM;1 1210011554
$ create/nolog 'f'
X!`009combine.COM - combine RMS records for group treatment by GREP, etc
X!
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`0
V32
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$
X$!`009if p1 .eqs. "" then p1 = 1
X$`009comb = P1
X$`009count= 0
X$
X$`009crlf`0910,8`093=13
X$`009crlf`0918,8`093=10
X$
X$`009newrec = ""
X$
X$READ:
X$`009READ/END=DONE SYS$INPUT LINE
X$`009newrec = newrec + line`032
X$`009count = count + 1
X$`009if count .ge. comb then goto write
X$
X$`009newrec = newrec + " " !crlf
X$`009goto read
X$
X$write:
X$`009WRITE SYS$OUTPUT newrec
X$`009newrec=""
X$`009count=0
X$`009GOTO READ
X$
X$DONE:
X$`009if newrec .nes. "" then write sys$output line
X$
$ CALL UNPACK COMBINE.COM;1 2032298764
$ create/nolog 'f'
X!       count.COM - count number of lines in input stream
X!`009`009  - optionally "tee" count
X!
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
X$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPU
VT`032
X
X$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUT
VPUT
X$
X$`009count = 0
X$
X$READ:  READ/END=DONE SYS$INPUT LINE
X!
X$`009count = count + 1
X!
X$       if p1 .nes. "" then WRITE SYS$OUTPUT LINE
X$       GOTO READ
X$DONE:
X$`009if p1 .eqs. "" then write sys$output count
X$`009if p1 .nes. "" then write 'p1 count
$ CALL UNPACK COUNT.COM;1 1847146071
$ create/nolog 'f'
X$!`009DCL  - to a DCL command to the data
X$!
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`0
V32
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$!
X$`009LINE = 'P1 'P2 'P3 'P4 'P5 'P6 'P7 'P8
X$!
X$`009WRITE SYS$OUTPUT LINE
X$`009GOTO READ
X$DONE:
$ CALL UNPACK DCL.COM;1 220334537
$ create/nolog 'f'
X1       ! grpDUP.BAS V1.0 - PIPE DUPS FINDER !
X        ON ERROR GOTO 32000
X
X        EXTERNAL LONG FUNCTION LIB$GET_FOREIGN
X        EXTERNAL INTEGER CONSTANT SS$_NORMAL
X
X        DIM P$(31)
X
X        DECLARE INTEGER CONSTANT        TRUE  = -1
X        DECLARE INTEGER CONSTANT        FALSE =  0
X
X        DECLARE INTEGER CONSTANT        INP = 1
X        DECLARE INTEGER CONSTANT        OUT = 2
X        DECLARE INTEGER CONSTANT        ECH = 3
X
X        COMMAND_BUFFER$ = SPACE$(80)
X
X        OPEN "SYS$OUTPUT"  FOR OUTPUT AS FILE #OUT,     &
X                RECORDSIZE 132
X        OPEN "SYS$COMMAND" AS FILE #ECH
X
X10      STATUS% = LIB$GET_FOREIGN(COMMAND_BUFFER$,,COMMAND_LENGTH%)
X        IF STATUS% <> SS$_NORMAL
X        THEN
X            PRINT #ECH, '%GET_COMMAND error'; STATUS%
X            GOTO 32767
X        END IF
X
X        CMD_CNT% = 0%
X
X        IF COMMAND_LENGTH% > 0%
X        THEN
X
X            COMMAND$ = LEFT$(COMMAND_BUFFER$,COMMAND_LENGTH%) + ' '
X
X            OS% = 0%
X            S% = INSTR(OS%+1%,COMMAND$,' ')
X
X            WHILE S% > 0%
X                CMD_CNT% = CMD_CNT%+1%
X                P$(CMD_CNT%) = MID$(COMMAND$,OS%+1%,S%-OS%-1%)
X                OS% = S%
X                S% = INSTR(OS%+1%,COMMAND$,' ')
X            NEXT
X
X        END IF
X
X        ! START AND END OF COMPARE
X        START% = VAL(P$(1%))
X        LENGTH% = VAL(P$(2%))
X        IF LENGTH% = 0%
X        THEN
X                LENGTH% = 999%
X        END IF
X
X        SAVED_LINE$ = ""
X        SAVED_SUBSTR$ = ""
X        SAVED_LINE_WRITTEN% = FALSE
X
X        LINLEN% = 0%
X        MAXLEN% = 128%
X
X100     LINPUT LINE$
X        SUBSTR$ = MID$(LINE$,START%,LENGTH%)
X        IF SUBSTR$ = SAVED_SUBSTR$
X        THEN
X            IF NOT SAVED_LINE_WRITTEN%
X            THEN
X                PRINT #OUT
X                PRINT #OUT, SAVED_LINE$; "   ";
X                LINLEN% = LEN(SAVED_LINE$)+3%
X                SAVED_LINE_WRITTEN% = TRUE
X            END IF
X            IF LINLEN%+LEN(LINE$) > MAXLEN%
X            THEN
X                PRINT #OUT, "-"
X                LINLEN%=0%
X            END IF
X            PRINT #OUT, LINE$; "   ";
X            LINLEN% = LINLEN%+LEN(LINE$)+3%
X        ELSE
X            SAVED_LINE$ = LINE$
X            SAVED_SUBSTR$ = SUBSTR$
X            SAVED_LINE_WRITTEN% = FALSE
X        END IF
X
X        GOTO 100
X
X
X32000   ! ERROR TRAPS
X
X        IF ERR=11       ! NORMAL EOF?
X        THEN
X                IF ERL=100
X                THEN
X                        PRINT #OUT
X                        RESUME 32767
X                END IF
X        END IF
X
X32100 ON ERROR GOTO 0   ! FATAL ERRORS
X
X32767 END
X
$ CALL UNPACK DUPS.BAS;1 537551969
$ create/nolog 'f'
X!       NODUPS.COM - REMOVES DUPLICATE RECORDS FROM TEXT FILES
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
X$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPU
VT`032
X$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUT
VPUT
X!
X$       OFFSET = P1
X$       LENGTH = P2
X$       IF LENGTH .EQ. 0 THEN LENGTH = 999      ! START AND END OF COMPARE
X!
X$       SAVED_SUBSTR = ""
X!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$       SUBSTR = F$EXTRACT(OFFSET,LENGTH,LINE)
X$       IF SUBSTR .EQS. SAVED_SUBSTR THEN GOTO READ
X$       SAVED_SUBSTR = SUBSTR
X$       WRITE SYS$OUTPUT LINE
X$       GOTO READ
X$DONE:
X
$ CALL UNPACK DUPS.COM;1 1531336782
$ create/nolog 'f'
X$!`009echo.COM - echo arguments
X$!
X$!`009WRITE SYS$OUTPUT "p1:''p1, p2:''p2, p3:''p3, p4:''p4, p5:''p5, "
X$`009WRITE SYS$OUTPUT "''p1' ''p2' ''p3' ''p4' ''p5' "
X$DONE:
$ CALL UNPACK ECHO.COM;1 622223558
$ create/nolog 'f'
X$!`009edit.COM - edit line with f$edit()
X$!`009`009 - arguments: p1: list of f$edit() operation eg: trim,compress
X$!
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`0
V32
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009WRITE SYS$OUTPUT f$edit(LINE,p1)
X$`009GOTO READ
X$DONE:
$ CALL UNPACK EDIT.COM;1 1968973785
$ create/nolog 'f'
X!`009element.COM - pass selected element of line
X!`009`009    - delimiter: any combination spaces/tabs
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`0
V32
X
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$`009PARTS = "F$ELEMENT('P1,"" "",LINE)
X$`009IF P2 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P2,"" "",LINE)
X$`009IF P3 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P3,"" "",LINE)
X$`009IF P4 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P4,"" "",LINE)
X$`009IF P5 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P5,"" "",LINE)
X$`009IF P6 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P6,"" "",LINE)
X$`009IF P7 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P7,"" "",LINE)
X$`009IF P8 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P8,"" "",LINE)
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009LINE = F$EDIT(LINE,"COMPRESS")
X$`009WRITE SYS$OUTPUT 'PARTS
X$`009GOTO READ
X$DONE:
$ CALL UNPACK ELEMENT.COM;1 928646472
$ create/nolog 'f'
X! EXTRACT.COM - pass selected element of line
X!
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`0
V32
X
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$`009PARTS := F$EXTRACT('P1,'P2,LINE)
X$`009IF P4 .NES. "" THEN PARTS = PARTS + "+F$EXTRACT('P3,'P4,LINE)"
X$`009IF P6 .NES. "" THEN PARTS = PARTS + "+F$EXTRACT('P5,'P6,LINE)"
X$`009IF P8 .NES. "" THEN PARTS = PARTS + "+F$EXTRACT('P7,'P8,LINE)"
X$
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009WRITE SYS$OUTPUT 'PARTS
X$`009GOTO READ
X$DONE:
$ CALL UNPACK EXTRACT.COM;1 427562485
$ create/nolog 'f'
X$! fil2dir - create directory spec from file spec
X$!
X$!`009dev:`091dir`093nam.typ;ver => dev:`091dir.nam`093
X$!
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`0
V32
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$
X$loop:
X$`009read sys$input/end=done parm
X$`009write sys$output -
X`009`009f$element(0,"`093",parm)-
X`009`009+"."-
X`009`009+f$element(0,".",f$element(1,"`093",parm))-
X`009`009+"`093"
X$`009goto loop
X$
X$done:
$ CALL UNPACK FIL2DIR.COM;14 890055752
$ create/nolog 'f'
X!item.com - get the item following a given item in a line
X! `009  - eg: in "name: kenw address: calgary", "item address" gets "calgary
V"
X$
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`0
V32
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$`009PARTS = "F$ELEMENT('P1,"" "",LINE)
X$`009IF P2 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P2,"" "",LINE)
X$`009IF P3 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P3,"" "",LINE)
X$`009IF P4 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P4,"" "",LINE)
X$`009IF P5 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P5,"" "",LINE)
X$`009IF P6 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P6,"" "",LINE)
X$`009IF P7 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P7,"" "",LINE)
X$`009IF P8 .NES. "" THEN PARTS = PARTS + "+"" ""+F$ELEMENT('P8,"" "",LINE)
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009LINE = F$EDIT(LINE,"COMPRESS")
X$`009WRITE SYS$OUTPUT f$element(1," ",f$extract(f$locate(p1,line),999,line))
X$`009GOTO READ
X$DONE:
$ CALL UNPACK ITEM.COM;1 1767254573
$ create/nolog 'f'
X! local_copies.com - compares revision dates of p1 and p2, copies p1 to p2 i
Vf`032
X!`009`009     anything has changed, and mails a message to p3
X!`009`009   - used with PIPE and local_copies.dat
X!
X$ if f$cvtime(f$file_attributes(p1,"rdt")) -
X`009.les.f$cvtime(f$file_attributes(p2,"rdt"))  -
X  then exit
X$
X$ copy 'p1 'p2
X$ pu 'p2/keep=2
X$ mail sys$input /to='p3/subject="''p1' has been copied to ''p2'"`032
X
XThis message was automatically generated by the 'LOCAL_COPIES' procedure.
XContact the system administrator if you  have any questions.
X
X$
$ CALL UNPACK LOCAL_COPIES.COM;1 523901583
$ create/nolog 'f'
XTITAN::USERS:`091PUBLIC.DOC`093WHOIS.LIS`009SYS$SYSTEM:WHOIS.LIS`009kenw
XTITAN::USERS2:`091GREEN`093DEPT.DIS`009`009SYS$MANAGER:DEPT.DIS`009letang
$ CALL UNPACK LOCAL_COPIES.DAT;1 1078621433
$ create/nolog 'f'
X/*
Xnoctrl.c - removes control characters from files
X`009 - useful for looking at ascii test in object files
X*/
X
X#define EOF -1
X
Xmain()
X`123
X        int byte,chrcnt;
X
X        chrcnt = 0;
X
X        while ( ( byte = getchar() ) != EOF )
X        `123
X                if      (byte > 31 & byte < 127)
X                `123
X                        putchar( byte );
X                        if (chrcnt++ > 76)
X                        `123
X                                printf( "\n" );
X                                chrcnt = 0;
X                        `125
X                `125
X        `125
X`125
X
$ CALL UNPACK NOCTRL.C;1 891367336
$ create/nolog 'f'
X!       NODUPS.COM - REMOVES DUPLICATE RECORDS FROM TEXT FILES
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
X$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPU
VT`032
X$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUT
VPUT
X!
X$       OFFSET = P1
X$       LENGTH = P2
X$       IF LENGTH .EQ. 0 THEN LENGTH = 999      ! START AND END OF COMPARE
X!
X$       SAVED_SUBSTR = ""
X!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$       SUBSTR = F$EXTRACT(OFFSET,LENGTH,LINE)
X$       IF SUBSTR .EQS. SAVED_SUBSTR THEN GOTO READ
X$       SAVED_SUBSTR = SUBSTR
X$       WRITE SYS$OUTPUT LINE
X$       GOTO READ
X$DONE:
X
$ CALL UNPACK NODUPS.COM;1 1531336782
$ create/nolog 'f'
X$ SAVE_VERIFY='F$VERIFY(FORCE_VERIFY)
X!
X! PIPE.COM v3.7 - DATA PIPE SIMULATOR
X!
X!   usage:    $ PIPE `091<infile`093 `091command `091args...`093`093 `091>ou
Vtfile`093 `091`124...`093
X!`009`009`009e.g.PIPE DIR `091*...`093 SORT `124DUPS >DUPLICATES.DIR
X!
X$! recent history:
X$! 890501 kenw`009fixed SYS$INPUT handling in shell mode
X$! 890424 kenw`009simplified parser, optimised
X$! 890412 kenw`009drop output channel opening; suggested by Brian Carcich
X$!
X$`009ON ERROR     THEN GOTO FINISH
X$`009ON CONTROL_Y THEN GOTO FINISH
X$!
X$`009DEASSIGN SYS$INPUT`009`009! PREPARE FOR PIPE I/O
X$`009DEASSIGN SYS$OUTPUT
X$!
X$`009TMPFILE="SYS$SCRATCH:"+F$GETJPI("","PID")+".PIPE;"
X$!
X$`009DEBUG_VERIFY=SAVE_VERIFY.AND.(F$MODE().EQS."INTERACTIVE")
X$`009`009`009`009`009! "set verify" interactive only
X$`009PIPE_DEBUG:='PIPE_DEBUG`009`009! PIPE debugging tools
X$`009DBO:=WRITE SYS$COMMAND
X$!
X$! FILTER symbol definitions for PIPE.COM`032
X$! note: this isn't the best way, but it's the fastest without global symbol
Vs
X$!
X$`009COMBINE`009:=@PIPE:COMBINE
X$`009COUNT`009:=@PIPE:COUNT
X$`009DI*RECT`009:=DIRECTORY/COLUMNS:1/NOHEADER/NOTRAILER
X$`009DUP*S`009:=$PIPE:DUPS
X$`009ECHO`009:=write sys$output """
X$`009EDIT`009:=@PIPE:EDIT
X$`009ELEM*ENT:=@PIPE:ELEMENT
X$`009EXTR*ACT:=@PIPE:EXTRACT
X$`009FIL2DIR`009:=@PIPE:FIL2DIR
X$`009FIND`009:=SEARCH/WIN=0/NOHEA
X$`009GREP`009:=SEARCH SYS$INPUT
X$`009GRP*DUP`009:=$PIPE:GRPDUP
X$`009ITEM`009:=@PIPE:ITEM
X$`009JUST*IFY:=@PIPE:JUSTIF
X$`009LS`009:='DI
X$`009MORE`009:=TYPE/PAGE SYS$INPUT
X$`009NOCTRL`009:=$PIPE:NOCTRL `032
X$`009NODUP*S`009:=@PIPE:NODUPS
X$`009SKIP`009:=@PIPE:SKIP
X$`009SORT`009:=SORT SYS$INPUT SYS$OUTPUT
X$`009TEE`009:=@PIPE:TEE
X$`009TOT*AL`009:=@PIPE:TOTAL
X$`009WIDE`009:=$PIPE:WIDE
X$!
X$`009TRUE=-1
X$`009FALSE=.NOT.TRUE
X$!
X$!
X$!Command Parsing
X$!===============
X$!
X$`009WCMD=F$EDIT(P1+" "+P2+" "+P3+" "+P4+" "+P5+" "+P6+" "+P7+" "+P8,-
X`009`009"COMPRESS,TRIM")
X$`009INTERACTIVE=WCMD.EQS.""
X$!
X$GET_WCMD:
X$`009IF INTERACTIVE THEN INQUIRE/NOPUNCT WCMD "`124 "
X$`009IF INTERACTIVE THEN WCMD=F$EDIT(WCMD,"COMPRESS,TRIM")
X$`009IF WCMD.EQS."" THEN GOTO EXIT
X$!
X$`009IF DEBUG_VERIFY THEN SHOW SYMBOL WCMD
X$`009IF PIPE_DEBUG THEN dbo "-GET_WCMD, P=`091",P,"`093`009",f$time()
X$!
X$`009R=0`009!parameter number
X$`009P=""`009!current parameter
X$`009PIPEFILE=TMPFILE
X$!
X$`009CMD=""`009!comand storage pseudo-array
X$`009INPT=""`009!input device storage pseudo-array
X$`009OUPT=""`009!output devide storage pseudo-array
X$`009PUSHING=FALSE
X$`009COND_PUSH= FALSE
X$!
X$!parser states
X$`009OPS=";`124<>\?+"
X$`009NTL=F$LENGTH(OPS)
X$`009STATE=NTL
X$!
X$PARSE:
X$`009IF P.NES."" THEN GOTO T_'STATE`009!check for unused args (eg on `124...
V)
X$!
X$`009P=F$ELEMENT(R," ",WCMD)
X$`009IF PIPE_DEBUG THEN dbo "-PARSE, P=`091",P,"`093`009",f$time()
X$`009IF P.EQS." " THEN GOTO DONE_PARSE
X$!
X$`009R=R+1
X$`009IF P.EQS."" THEN GOTO T_'NTL`009!handle quoted spaces
X$!
X$!`009idea:`009add state pre-checker for 2-char: `124<,`124>,`124;, etc
X$!`009`009eg:`009STATE=F$LOCATE(F$EXTRACT(0,2,P)+"  ","`124`124 `124< `124>"
V)/3
X$!`009`009`009IF STATE.LT.3 THEN GOTO T_'STATE'+NTL
X$!
X$`009STATE=F$LOCATE(F$EXTRACT(0,1,P),OPS)
X$`009IF STATE.NE.NTL THEN P=F$EXTRACT(1,999,P)`009!strip the operator
X$`009GOTO T_'STATE
X$!
X$T_0:`009!multiple command w/o piping - ;
X$`009GOSUB EXECUTE
X$`009GOTO NEXT_CMD
X$!
X$T_1:`009!pipe redirect - `124
X$`009IF OUPT.EQS."" THEN OUPT=PIPEFILE !allow ">" to override "`124"
X$`009GOSUB EXECUTE
X$`009INPT=PIPEFILE
X$`009PIPEFILE=TMPFILE
X$!
X$NEXT_CMD:`009!handle end of a command section
X$`009OUPT=""
X$`009CMD=""
X$`009PUSHING=FALSE
X$`009COND_PUSH= FALSE
X$`009STATE=NTL`009!pass any argument (P) back to neutral parser
X$`009GOTO PARSE`009`009`009!***
X$!
X$T_2:`009!input redirection - <
X$`009INPT=P
X$`009GOTO CLEAR_STATE
X$!
X$T_3:`009!output redirection - >
X$`009OUPT=P
X$`009PIPEFILE="NL:"
X$`009GOTO CLEAR_STATE
X$!
X$T_4:`009!escape: neutral - \
X$`009P=F$EXTRACT(1,999,P)
X$`009GOTO T_'NTL
X$!
X$T_5:`009!conditional pipe - ?
X$`009COND_PUSH=TRUE
X$!
X$T_6:`009!data as argument - +
X$`009PUSHING=TRUE`032
X$!
X$T_7:`009!neutral/command - no operator
X$`009CMD=CMD+" "+P
X$!
X$CLEAR_STATE:
X$`009P=""
X$`009STATE=NTL`009!input state is satisfied
X$`009GOTO PARSE
X$!
X$DONE_PARSE:
X$`009CMD=CMD+" "+P
X$`009GOSUB EXECUTE
X$`009GOTO FINISH
X$!
X$!
X$!Execute the Command Line
X$!========================
X$!
X$EXECUTE:
X$!`009IF DEBUG_VERIFY THEN sh sym cmd
X$`009IF PIPE_DEBUG THEN dbo "-exec, cmd=`091",cmd,"`093`009",f$time()
X$!
X$`009OCMD=CMD`009`009`009`009! Save original command
X$!
X$! open channels
X$!
X$`009IF "''INPT'".EQS."" THEN $GOTO 1`009! PREPARE INPUT CHANNEL
X$`009    OPEN PIPE_INPUT 'INPT
X$`009    IF.NOT.pushing THEN ASSIGN/NOLOG PIPE_INPUT SYS$INPUT
X$`0091:
X$!
X$`009IF "''OUPT'".EQS."" THEN $GOTO 2`009! PREPARE OUTPUT CHANNEL
X$`009    ASSIGN/NOLOG 'oupt PIPE_OUTPUT`032
X$`009    ASSIGN/NOLOG PIPE_OUTPUT SYS$OUTPUT
X$`0092:
X$!
X$! loop control
X$`009IF.NOT.pushing THEN GOTO 2_3`009!if "pushing", read data first
X$!
X$2_1:
X$`009READ/END=2_5 PIPE_INPUT LINE`009! read data for "+" commands
X$!
X$`009CMD=OCMD`009`009`009! restore original command
X$`009X=F$LOCATE("&LINE",CMD)
X$`009IF X.LT.F$LENGTH(CMD) THEN GOTO IN_LINE
X$!
X$`009`009CMD=CMD+" "+LINE`009!if the "&LINE" symbol is not in the`032
X$`009`009`009`009`009!command, tack it on the end
X$`009`009IF PIPE_DEBUG THEN dbo "-outline, cmd=`091",cmd,"`093`009"
X$`009`009GOTO 2_2
X$!
X$`009IN_LINE:
X$`009`009CMD=F$EXTRACT(0,X,CMD)+LINE+F$EXTRACT(X+5,999,CMD)
X$`009`009`009`009`009! else stick it in the middle
X$`009`009IF PIPE_DEBUG THEN dbo "-inline, cmd=`091",cmd,"`093`009"
X$`009`009XX=F$LOCATE("&LINE",CMD)! look for more
X$`009`009IF XX.GE.F$LENGTH(CMD) THEN GOTO 2_2
X$`009`009IF XX.LE.X+F$LENGTH(LINE) THEN GOTO 2_2
X$`009`009`009`009`009! trap resursive substitutions
X$`009`009X=XX
X$`009`009GOTO IN_LINE
X$!
X$2_2:
X$`009IF.NOT.COND_PUSH THEN GOTO 2_3
X$`009`009READ SYS$COMMAND DOIT/ERROR=FINISH/END=FINISH -
X`009`009`009/PROMPT="$''CMD' `091Y`093? "
X$`009`009DOIT=F$EDIT(DOIT,"UPCASE,TRIM")
X$`009`009IF DOIT.EQS."" THEN DOIT="Y"
X$`009`009IF DOIT THEN GOTO 2_3
X$`009`009IF DOIT.NES."ALL" THEN GOTO 2_1
X$`009`009COND_PUSH=FALSE
X$!
X$2_3:
X$! do the command
X$`009PIPE_JUNK=F$VERIFY(DEBUG_VERIFY)`009! restore external verify
X$`009SET NOON
X$ 'CMD
X$`009SET ON
X$`009!'F$VERIFY(FORCE_VERIFY)`009`009! restore internal verify
X$2_4:
X$`009IF pushing THEN GOTO 2_1`009!if "pushing", repeat command until`032
X$`009`009`009`009`009!there is no more data in the pipe
X$!
X$! close channels
X$!
X$2_5:
X$`009IF "''INPT'".EQS."" THEN $GOTO 3`009! cleanup for input channel
X$`009    IF.NOT.pushing THEN DEASSIGN SYS$INPUT
X$`009    CLOSE PIPE_INPUT
X$`009    IF F$SEARCH("PIPE_INPUT").NES."" THEN DELETE PIPE_INPUT
X$`0093:
X$!
X$`009IF "''OUPT'".EQS."" THEN $GOTO 4`009! cleanup for output channel
X$`009    DEASSIGN SYS$OUTPUT
X$`009    DEASSIGN pipe_OUTPUT
X$`0094:
X$!
X$
X$ RETURN
X$!
X$
X$!
X$! Cleanup and exit
X$!=================
X$!
X$FINISH:
X$`009IF PIPE_DEBUG THEN dbo "-finish`009",f$time()
X$`009@NL:`009`009`009`009! force image exit
X$`009DEASSIGN SYS$INPUT
X$`009DEASSIGN SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES."" THEN CLOSE PIPE_INPUT
X$`009IF F$LOGICAL("PIPE_OUTPUT").NES."" THEN deass pipe_OUTPUT
X$!
X$`009IF INTERACTIVE THEN GOTO GET_WCMD
X$!
X$EXIT:
X$`009IF F$SEARCH(TMPFILE).NES."" THEN DELETE 'TMPFILE'*
X$!
X$`009EXIT $STATUS+0*F$VERIFY(SAVE_VERIFY)`009! RESTORE VERIFY
X$!
X$! 890406 kenw`009drop input redirection in "push" mode
X$! 890403 kenw`009correct verify handling to handle batch properly
X$! 890402 kenw`009added "?" operator, interactive mode
X$! 890219 kenw`009make &LINE handler manual, add FIL2DIR filter
X$! 890126 kenw`009add quoted-string parser
X$! 890124 kenw`009add 'item' filter
X$! 890120 kenw`009turn off verify in batch
X$! 890105 kenw`009add "+" operator to replace '&LINE' for in-line data,
X$!`009`009changed definition of 'echo' to symbol
X$! 890104 kenw`009add ";" operator for multiple sequential command lines
X$! 881201 kenw`009changed scratch file naming to make unique
X$! 880713 kenw`009Fix verify handling: "'" in front of F$VERIFY causes it
X$!`009`009to execute BEFORE interpreting, else vice versa.
X$!`009`009Added "seen command" display.
X$!
X$!
X$!`009setup definitions:
X$!`009`009symbol PIPE for command execution
X$!`009`009logical PIPE for package location (default: PIPE.COM location)
X$!
X$!`009there are 3 major sections:
X$!`009`009initialization - define local symbols
X$!`009`009parsing - take a command from SYS$INPUT, parse it
X$!`009`009execution - process the command
X$!
X$!`009bugs:
X$!`009`009- there may be some problems with input by command files
X$!`009`009with redirected channels under wierd circumstances; caused`032
X$!`009`009by DCL switching source of input at EOF.
X$!`009`009- top-level I/O redirection will not work properly within`032
X$!`009`009command files.  DCL lies about filespecs and doesn't stack`032
X$!`009`009them.
X$!`009`009- VERFIFY handling is tricky, since there is no DCL equivalent
X$!`009`009to DEBUG's input/output redirection logicals. VFY$INPUT/OUTPUT
X$!`009`009would allow debugging without corruption of data.
X$!`009`009- control-Y handling awkward with called DCL.
$ CALL UNPACK PIPE.COM;102 1159008218
$ create/nolog 'f'
X1`009PIPE
X`009$ P*IPE `091 <fromfile`093 `091 +`093`091command...`093 `091""`093`091ar
Vgs`093`091""`093 `091&line`093`032
X`009`091 >tofile`093 `091 `124 ...`093 `091 ; ...`093
X
X`009eg: pipe SHOW LOGICALS * `124 grep DU `124 srt >LP:
X
X2`009Operators
X`009<filespec    redirects input to come from 'filespec'
X`009>filespec    redirects output to go to 'filespec'
X`009`124            'pipe the output from a the previous command to the`032
X`009             input of the next
X`009;            separate the previous command from the next _without_
X`009             piping
X`009+            switch mode of command from 'execute with data as input'
X`009             to 'execute with data as argumants'
X`009?            same as '+', but confirms each command execution
X`009&LINE        not really an operator, more a 'reserved symbol'.  Used`032
X`009             with '+' and '?' to place the data _within_ a command`032
X                     line.  Note that the use of uppercase is NOT optional.
X`009""           pass a single quote (") to DCL when the command is`032
X`009             executed.  Confusing, but DCL makes it necessary.
X
X`009All PIPE operators MUST be preceeded by a space or tab, otherwise they`0
V32
X`009will not be recognized as such.
X
X2`009COMBINE
X`009COMBINE groups of sequential lines of input into one output record
X
X2`009COUNT
X`009Counts number of lines/entries`032
X
X2`009DI*RECTORY
X`009DIRECTORY filespec
X
X`009Single-column filespec-only directory to provide lists of filenames
X
X`009Note: This is intended to override any other similar definition
X`009      while in PIPE.
X
X2`009DUPS
X`009DUPS start length
X
X`009Finds duplicate entries in the specified portion of the line
X
X`009eg: PIPE DIR `124 DUPS 1 10
X
X2`009EDIT
X`009EDIT edit_options
X
X`009Performs a DCL F$EDIT (eg: UPCASE,TRIM) on each line of text
X
X2`009ELEMENT
X`009ELEMENT  element_number `091...`093
X
X`009Performs a DCL F$ELEMENT(n," ",line) on each line of input, where
X`009the first element is 0, and " " represents any combination of spaces
X`009and tabs`032
X
X2`009EXTRACT`032
X`009EXTRACT offset length `091... ...`093
X
X`009Performs a DCL F$EXTRACT(P1,P2,line) on each line of input
X
X2`009FIND`032
X`009FIND filespec search_spec
X
X`009Finds files containing given search arguments. Returns filespec only,`03
V2
X`009for further action, eg: pipe find auditer `124 +edit
X
X2`009GREP`032
X`009GREP search_spec
X
X`009Pass only entries containing given text.  Supports all SEARCH`032
X`009options.  Exactly equivalent to SEARCH SYS$INPUT
X
X2`009ITEM`032
X`009ITEM _text_ `091...`093
X
X`009Element following element containing _text_.
X
X2`009LOCAL_COPIES
X`009Update local copies of files as needed, according to input`032
X`009parameters.   Could be modified to be a MAKE.
X
X2`009JUSTIFY
X`009JUSTIFY`009find_char to_column `091find_char to_column...`093
X
X`009Useful for using context to align data into columns, suchs as
X`009aligning all file extensions prior to sorting.
X
X`009Not currently inplemented
X
X2`009MORE
X`009    Exactly equivalent quivalent to TYPE/PAGE SYS$INPUT
X
X2`009NOCTRL
X`009Filters out control characters - allows viewing binary files for
X`009embedded text.
X
X2`009SKIP`032
X`009SKIP number_of_lines
X
X`009Skips the first number_of_lines lines (eg: headers) in the input
X
X2`009TEE`032
X`009TEE filespec
X
X`009Writes a copy of the input to the specified file. Defaults to`032
X`009SYS$COMMAND
X
X2`009TOTAL`032
X`009TOTAL start-column length `091... ...(I think)`093
X
X`009Total value of all entries in given columns
X
X2`009UNIQ
X`009Everything BUT duplicates (See NODUPS). Input _must_ be in same`032
X`009sorted order.
X`009
X2`009WIDE
X`009Prints lists in wide format
X
X2`009Examples
X`009A selective SHOW SYSTEM
X`009`009$ gs :== 'pipe show system `124grep`032
X`009`009$ gs up    or     $ gs acp     etc
X
X`009An 'appropos' or 'index' for VMS HELP
X`009`009$ pipe <nl: help lex f$* * `124grep f$,node
X
X`009Delete empty files
X`009`009$ pipe dir */sel=siz=max=0/siz=used `124 +delete/confirm
X
X`009Wildcard DEASSIGN
X`009`009$ pipe sho log news$* `124element 1 `124skip 9 `124 +deassign/sys
X
X`009Wildcard SHOW TERMINAL
X`009`009$ pipe sho dev t `124element 1 `124skip 2 `124 +sho ter `124grep dev
V,dma
X
X`009Wildcard EDIT
X`009`009$ pipe DIR PS*.FOR `124 +edit
X
X`009Show processes with specific files open, or vice versa, or both
X`009`009$ pipe sho dev dua0/files `124grep junk.dat
$ CALL UNPACK PIPE.HLP;5 35217749
$ create/nolog 'f'
X! PIPE_LOGIN.COM - symbol definitions for PIPE package - K. Wallewein ARC 89
V0127
X! note: PIPE assumes that all files in the this package are located in the`0
V32
X!       same directory
X!
X$`009! determine procedure location
X$`009here=F$PARSE(F$ENVIRONMENT("PROCEDURE"),,,,"NO_CONCEAL")-"`093`091"
X$`009here=F$EXTRACT(0,F$LOCATE("`093",here),here)
X$
X$`009DEFINE PIPE 'here'`093
X$
X$`009P*IPE`009`009:== @PIPE:PIPE """"`009! pass everything verbatim
X$`009SUBS*TITUTE`009:== @PIPE:SUBSTITUTE
X$`009PA`009`009:== @PIPE:PURGABLE`009! do NOT use PU*RGABLE!!!
X$`009DO`009`009:== SPAWN/NOWAIT/NOTIFY -
X`009`009`009`009/INPUT=NL:/OUTPUT=SYS$SCRATCH:DO.LOG
X$`009`009`009`009`009`009! easy background tasks
X$`009FORCE_VERIFY`009== "''FORCE_VERIFY'"`009! be sure it's defined for PIPE
X$
$ CALL UNPACK PIPE_LOGIN.COM;1 1148470783
$ create/nolog 'f'
XMessage pipe:124 -  Unsent
XFrom:    Ken Wallewein <kenw%noah.arc.cdn@relay.ubc.ca>
XTo:      <info-vax@kl.sri.com>
XSubject: PIPE for VMS
X
X  Looks like people are starting to talk about I/O redirection on VMS again,
V`032
Xso maybe it's time to re-post this.
X
X  I have written a facility I call PIPE for VMS, which allows one to pipe`03
V2
Xdata between VMS commands, etc.  But it's more than that.  Here's a summary.
X
X   - allows combining DCL commands to operate data without worrying about
X     temporary intermediate files., eg:`032
X
X`009  $ pipe SHOW LOGICAL * `124grep TT,TX `124sort >lp:
X`009  $! shows only logicals pointing directly to TT and TX devices
X
X   - provides wildcard filespecs for any command, eg:
X
X`009  $ pipe dir *.FOR `124 +edit`032
X`009  $! edits every .FOR file.`032
X
X  `009The '+' switches the mode to 'execute with data as args' from the`032
X`009default 'execute with data as input'.
X
X   - allows multiple commands to be executed sequentially, as in:
X`009   $ pipe show users > OPA0: ;sho sys >OPA0:
X
X   - allows redirection of output for programs which don't normally`032
X     support this, eg:`032
X`009   $ pipe authorize show brief * >lp:
X
X   - allows more selective outputs from programs, eg:
X`009   $ p show system `124grep acp,symb
X`009   $! show only ACPs and SYMBIONTs
X
X   - provides an effective /CONFIRM option on commands that don't otherwise`
V032
X     allow it (like COPY), eg:
X`009   $ pipe dir foo*/exc:.exe `124 ?copy &LINE dua1:`091archives`093
X           $! note: "?" is like "+", with confirm
X
X  Installation of PIPE is dead easy.
Xa)  Put all of the files in one directory. `032
Xb)  @PIPE_LOGIN.COM to sets up the PIPE logical and symbol.
X
X  Note: PIPE is _not_ device driver wizardry.  Because its functionality`032
Xis so tied to DCL, the PIPE main routine is itself written mostly in DCL.
XThe filters vary.
X
X  More examples:
X
X`009A convenient selective SHOW SYSTEM
X`009`009$ gs :== 'pipe show system `124grep`032
X`009`009$! e.g.:  $ gs up     $ gs acp     etc.
X
X`009An 'appropos' or 'index' for VMS HELP
X`009`009$ pipe <nl: help lex f$* * `124grep f$,node
X
X`009Delete empty files
X`009`009$ pipe dir */sel=siz=max=0/siz=used `124 +delete/confirm
X
X`009Wildcard DEASSIGN
X`009`009$ pipe sho log news$* `124element 1 `124skip 9 `124 +deassign/sys
X
X`009Wildcard SHOW TERMINAL
X`009`009$ pipe sho dev t `124element 0 `124skip 2 `124 +sho ter `124grep dev
V,dma
X
X`009Show processes with specific files open, or vice versa, or both
X`009`009$ pipe sho dev dua0/files `124grep junk.dat
X
X`009Wildcards for SYSGEN and INSTAL...
X
X
X  PIPE is available via mail in VMS_SHARE format for the asking.  If I get`0
V32
Xenough requests, I'll post it.  It totals about 100 blocks, last I checked.
X
X
XKen Wallewein                                                     A L B E R
V T A
Xkenw@noah.arc.cdn                                               R E S E A R
V C H
X(403)297-2660                                                     C O U N C
V I L
X
X
$ CALL UNPACK PIPE_MESSAGE.LIS;1 589915615
$ create/nolog 'f'
X$ say "purgable.com - show purgable files"
X$ say "working..."
X$
X$ on error then goto exit
X$ on control_y then goto exit
X$
X$ file_name := SYS$SCRATCH:purgable.lis
X$
X$ dir/notr/siz/col=1/out='file_name 'p1
X$ filnam1 = f$search(file_name)
X$
X$ dir/notr/siz/col=1/out='file_name 'p1;
X$ filnam2 = f$search(file_name)
X$
X$ diff/sep=master 'filnam1 'filnam2
X$
X$exit:
X$ if "''filnam1'" .nes. "" then delete 'filnam1
X$ if "''filnam2'" .nes. "" then delete 'filnam2
$ CALL UNPACK PURGABLE.COM;1 554239451
$ create/nolog 'f'
X! SKIP.COM - skip n lines at beinning of input`032
X!`009   - synopsis: skpi lines
X!
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
X$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPU
VT`032
X$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUT
VPUT
X$
X$`009skipcnt = f$integer(p1)+1
X$SKIP:`009skipcnt = skipcnt-1
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`009if skipcnt .ne. 0 then goto skip
X$`009WRITE SYS$OUTPUT line
X$       GOTO READ
X$DONE:
$ CALL UNPACK SKIP.COM;1 2084386474
$ create/nolog 'f'
X! squish6 !
Xersys$input`027
Xewsys$output`027
X<
X hk
X 6<1:a"u oDONE`027'> ! read lines !
X bj <:@fs/`094m`094j/ /;> bj <:@fs/`094es/ /;> ! squish !
X hpw
X>
X!DONE!
Xbj <:@fs/`094m`094j/ /;> bj <:@fs/`094es/ /;>`032
Xex`027`027
$ CALL UNPACK SQUISH6.TEC;3 1952062134
$ create/nolog 'f'
X! squish8 !
Xersys$input`027
Xewsys$output`027
X<
X hk
X 8<1:a"u oDONE`027'> ! read 8 lines !
X bj <:@fs/`094m`094j/ /;> bj <:@fs/`094es/ /;> ! squish !
X hpw
X>
X!DONE!
Xbj <:@fs/`094m`094j/ /;> bj <:@fs/`094es/ /;>`032
Xex`027`027
$ CALL UNPACK SQUISH8.TEC;9 609639497
$ create/nolog 'f'
X1       ! STEM.BAS V1.0 - PIPE STEM !
X        ON ERROR GOTO 32000
X
X        EXTERNAL LONG FUNCTION LIB$GET_FOREIGN
X        EXTERNAL INTEGER CONSTANT SS$_NORMAL
X
X        DIM P$(31)
X
X        COMMAND_BUFFER$ = SPACE$(80)
X
X        OPEN "SYS$COMMAND" AS FILE #1%
X
X10      STATUS% = LIB$GET_FOREIGN(COMMAND_BUFFER$,,COMMAND_LENGTH%)
X        IF STATUS% <> SS$_NORMAL
X        THEN
X            PRINT #1%, '%GET_COMMAND error'; STATUS%
X            GOTO 32767
X        END IF
X
X        CMD_CNT% = 0%
X
X        IF COMMAND_LENGTH% > 0%
X        THEN
X
X            COMMAND$ = LEFT$(COMMAND_BUFFER$,COMMAND_LENGTH%) + ' '
X
X        !   PRINT #1%, 'COMMAND WAS: "'; COMMAND$; '"'
X
X            OS% = 0%
X            S% = INSTR(OS%+1%,COMMAND$,' ')
X
X            WHILE S% > 0%
X                CMD_CNT% = CMD_CNT%+1%
X                P$(CMD_CNT%) = MID$(COMMAND$,OS%+1%,S%-OS%-1%)
X        !       PRINT #1%, 'P$(';CMD_CNT%;'): "'; P$(CMD_CNT%); '"'
X                OS% = S%
X                S% = INSTR(OS%+1%,COMMAND$,' ')
X            NEXT
X
X20      ! READ LOOP
X        LINPUT A$
X        GOSUB 100
X        PRINT A$
X        GOTO 20
X
X100     ! YOUR CODE HERE
X        ! NOTE:
X        !       AVAILABLE HERE ARE THE FOLLOWING COMMAND LINE VARIABLES:
X        !       COMMAND$ - CONTAINS ALL OPTIONS INCLUDED WITH THE COMMAND
X        !       P$()     - CONTAINS OPTIONS PARSED BY SPACES
X        !       CMD_CNT% - CONTAINS NUMBER OF OPTIONS FOUND
X
X999     RETURN
X
X32000   ! ERROR TRAPS
X
X        IF ERR=11       ! NORMAL EOF?
X        THEN
X                IF ERL=20
X                THEN
X                        RESUME 32767
X                END IF
X        END IF
X
X32100 ON ERROR GOTO 0   ! FATAL ERRORS
X
X32767 END
X
$ CALL UNPACK STEM.BAS;1 1746151268
$ create/nolog 'f'
X/* stem.c v1.0 - pipe stem */
X
X#define EOF -1
X
Xmain()
X`123
X        int byte;
X
X        while ( (byte=getchar()) != EOF )
X        `123
X                /* your code here */
X                putchar( byte );
X        `125
X`125
X`032
X
$ CALL UNPACK STEM.C;1 1380208176
$ create/nolog 'f'
X$!`009PIPESTEM.COM - STUB FRONT END FOR COM FILES USED BY PIPE
X$!
X$`009DEASS SYS$INPUT
X$`009DEASS SYS$OUTPUT
X$`009IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPUT`0
V32
X$`009IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUTPUT
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$!
X$!`009PUT CODE HERE...
X$!
X$`009WRITE SYS$OUTPUT LINE
X$`009GOTO READ
X$DONE:
$ CALL UNPACK STEM.COM;1 1312981018
$ create/nolog 'f'
X/* stems.c - line oriented c pipestem */
X
Xchar *string`091255`093;
X
Xmain()
X`123
X        while ( gets( string ) )
X        `123
X
X                /* your code here */
X
X                puts( string );
X        `125
X`125
X
$ CALL UNPACK STEMS.C;1 573192461
$ create/nolog 'f'
X!SUBSTITUTE.COM V1.0 - search/substitute on a file using FORALL and EDT
X!
X$    on error then goto edit
X$    on control_y then goto exit
X$
X$    if p1 .eqs. "" .or. p2 .eqs. "" then goto badargs
X$
X$    file_name := SYS$SCRATCH:SUBSTITUTE.EDT
X$
X$    open/write file 'file_name
X$    filnam = f$search(file_name)
X$
X$    write file "subs`126''p2'`126''p3'`126w/not"
X$    write file "ex"
X$    close file
X$
X$    pipe dir 'p1 `124 +EDITt/COMMAND='filnam
X$    goto exit
X$
X$badargs:
X$    write sys$output "SUBSTITUTE filespec search_string `091substitute_stri
Vng`093"
X$
X$exit:
X$    if f$trnlnm("file") .nes."" then -
X            close file
X$    if "''filnam'" .nes. "" .or. f$trnlnm("file") .nes."" then -
X            delete 'filnam
$ CALL UNPACK SUBSTITUTE.COM;2 625871281
$ create/nolog 'f'
X! tabify !
Xersys$input`027
Xewsys$output`027
X<
X 1:a"u oDONE`027'
X <:@fs/ /`009/;>
X hpw hk
X>
X!DONE!
Xex`027`027
$ CALL UNPACK TABIFY.TEC;1 1583305451
$ create/nolog 'f'
X!       tee.COM - send a copy of sys$input to specified file
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
X$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPU
VT`032
X$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUT
VPUT
X$
X$`009if p1 .eqs. "" then p1 := tt:
X$
X$`009open/write file 'p1
X$
X$READ:  READ/END=DONE SYS$INPUT LINE
X$`032
X$`009write file line
X$
X$       WRITE SYS$OUTPUT LINE
X$       GOTO READ
X$DONE:
X$`009close file
$ CALL UNPACK TEE.COM;1 1148747366
$ create/nolog 'f'
X!time.com - times stuff
X!
X$`009prev_time = "''time'"
X$`009time == 'f$cvtime(,,"second")*100 + 'f$cvtime(,,"hundredth")
X$`009elapsed = time - prev_time
X$
X$CMD := 'P1 'P2 'P3 'P4 'P5 'P6 'P7 'P8
X$
X$`009IF CMD .EQS. "" THEN goto done
X$
X$'cmd
X$
X$`009prev_time = 'time
X$`009time == 'f$cvtime(,,"second")*100 + 'f$cvtime(,,"hundredth")
X$`009elapsed = time - prev_time
X$
X$done:
X$`009secs = elapsed/100
X$`009hund = elapsed - secs*100
X$`009write sys$output "elapsed: ''secs'.''hund'"
$ CALL UNPACK TIME.COM;1 1565686740
$ create/nolog 'f'
X$! timer.com - for timing DCL code
X$!
X$ c = 0
X$ max=20
X$ if p1 .nes. "" then max=p1
X$
X$ T=F$GETJPI("","CPUTIM")
X$
X$LOOP:
X$!
X$!
X$!
X$!
X$!
X$!
X$ C=C+1
X$ IF C.LT.MAX THEN GOTO LOOP
X$
X$ T2=F$GETJPI("","CPUTIM")
X$
X$ say "elapsed: ", t2-t-3*max-max/5
$ CALL UNPACK TIMER.COM;12 1346500199
$ create/nolog 'f'
X!       TOTAL.COM - total up all items in given column
X!`009`009  - parameters: column_offset length `091output_file`093
X!
X$       DEASS SYS$INPUT
X$       DEASS SYS$OUTPUT
X$       IF F$LOGICAL("PIPE_INPUT") .NES. "" THEN ASSIGN PIPE_INPUT  SYS$INPU
VT`032
X$       IF F$LOGICAL("PIPE_OUTPUT") .NES. "" THEN ASSIGN PIPE_OUTPUT SYS$OUT
VPUT
X$!
X$`009total = 0
X$!
X$READ:  READ/END=DONE SYS$INPUT LINE
X$!
X$`009total = total + f$integer(f$extract('p1,'p2,line))
X$!
X$       if p3 .nes. "" then WRITE SYS$OUTPUT line
X$       GOTO READ
X$DONE:
X$       if p3 .eqs. "" then WRITE SYS$OUTPUT total
X$       if p3 .nes. "" then WRITE 'p3 total
$ CALL UNPACK TOTAL.COM;1 779694361
$ create/nolog 'f'
X1       ! WIDE.BAS V1.0 - PIPE WIDE LIST PRINTER !
X        ON ERROR GOTO 32000
X
X        EXTERNAL LONG FUNCTION LIB$GET_FOREIGN
X        EXTERNAL INTEGER CONSTANT SS$_NORMAL
X
X        DECLARE INTEGER CONSTANT        TRUE  = -1
X        DECLARE INTEGER CONSTANT        FALSE = 0
X
X        DECLARE INTEGER CONSTANT        OUT   = 2
X
X        COMMAND_BUFFER$ = SPACE$(80)
X
X        OPEN "SYS$OUTPUT"  FOR OUTPUT AS FILE #OUT,     &
X                RECORDSIZE 132
X
X10      STATUS% = LIB$GET_FOREIGN(COMMAND_BUFFER$)
X        MAXLEN% = VAL(COMMAND$)
X        MAXLEN% = 128%  UNLESS MAXLEN%
X
X        LINLEN% = 0%
X
X100     LINPUT LINE$
X
X        IF LINLEN%+LEN(LINE$) > MAXLEN%
X        THEN
X                PRINT #OUT
X                LINLEN%=0%
X        END IF
X        PRINT #OUT, LINE$; "   ";
X        LINLEN% = LINLEN%+LEN(LINE$)+3%
X
X        GOTO 100
X
X
X32000   ! ERROR TRAPS
X
X        IF ERR=11       ! NORMAL EOF?
X        THEN
X                IF ERL=100
X                THEN
X                        PRINT #OUT
X                        RESUME 32767
X                END IF
X        END IF
X
X32100 ON ERROR GOTO 0   ! FATAL ERRORS
X
X32767 END
X
$ CALL UNPACK WIDE.BAS;1 1761703608
$ EXIT
