bruceb@amiga.UUCP (Bruce Barrett) (02/24/86)
Guess what. You can use "pipes" on the Amiga to pipe the output of one process to the input of another. This requires: no C code no programming knowlege the enclosed execute file. While AndyF and I were discussing the spool execute files he remarked, "You know, this means we can do pipes!" (Not a direct quote, but that was the spirit of the thing.) Well I gave it some thought and agreed. Then I wrote the following execute file. It works. Copies of this file (hardcopy) were passed out at last nights BADGE meeting at SRI, Menlo Park. Enjoy!! ---------------------------------------- Comments about the PIPE execute file: 1) Command syntax: EXECUTE PIPE command_1 arg1 ... argn | command_2 arg1 ... argn 2) This version allows a total of two (2) commands (or programs) and eight (8) arguments. The arguments may be used by either command, or both in any combination. The execute file could be expanded to handle more options. 3) Sample usage: EXECUTE PIPE echo "20-Feb-86" | date "?" { note: if you leave off the " around the ? EXECUTE thinks you want it to tell you about the command format for PIPE } EXECUTE PIPE dir | more EXECUTE PIPE dir df1: opt a | more 4) All of this will work faster if you run it out of RAM:. 5) Almost none of the AmigaDOS commands use standard input if no parameters are given. This is a problem which should be addressed. We (the developer/user comunity at large, not Amiga) need to create UN*X style tools like MORE, SORT,... 6) It would be even more convenient if we did not have to eliminate stray parameters from the end of the line (we could delete lines 17-41 and line 44) but for the first example I used (see # 3 above) this will not work. If the DATE command detects characters past its last parameter (even spaces) it displays "Bad Args". 7) Comments referring to the execute file by line number: Line 1, define 11 optional arguments. Actually c1, c2, and c3 could be made required. FLAG could be made a keyword. lines 3 and 4, redefine the bracketing characters (the default is "<" and ">" but these are needed for redirection). Lines 1, 6, 11 and 51, the parameter FLAG is intended for internal use only. The user should not specify it. The FLAG parameter is used to determine the state of the execute file, as follows: FLAG = "", the user just executed this file. FLAG = "is|?", we are looking for c2 to match the "|" (pipe character). FLAG = "DoIt", c1 and c2 are set up for running, run them and delete the intermediate pipe file (RAM:PIPE$$$) Lines 6-9, This is the first time we've been called, change c1 to redirect its output to the pipe file. Lines 11-49, What to do if we are still looking for the "|" character. We add c2 to c1 and execute our self recursively. Lines 12-15, What to do if we never find the "|" character, and run out of parameters looking for it. Print error and exit. Lines 16-48, We've found the "|" character so let's call our self once more eliminating any "stray" parameters and spaces (sigh). Lines 51-55, We were just called with DoIt as a parameter, c1 and c2 are now set up correctly, lets run them. ------============================================================------ 1 .KEY c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,FLAG 2 . PIPE, an execute file that does pipes! By: Bruce Barrett. Public Domain 3 .bra { 4 .ket } 5 6 if "{FLAG}" eq "" 7 execute PIPE "{c1} > RAM:PIPE$$$" "{c2}" "{c3}" "{c4}" "{c5}" "{c6}" "{c7}" "{c8}" "{c9}" "{ca}" "{cb}" "is|?" 8 skip END 9 endif 10 11 if "{FLAG}" eq "is|?" 12 if "{c2}" eq "" 13 echo "PIPE: Error, no *"|*" (bar) found!" 14 skip END 15 endif 16 if "{c2}" eq "|" 17 if "{c4}" EQ "" 18 execute PIPE "{c1}" "{c3} < RAM:PIPE$$$" "" "" "" "" "" "" "" "" "" "DoIt" 19 skip END 20 endif 21 if "{c5}" EQ "" 22 execute PIPE "{c1}" "{c3} < RAM:PIPE$$$ {c4}" "" "" "" "" "" "" "" "" "" "DoIt" 23 skip END 24 endif 25 if "{c6}" EQ "" 26 execute PIPE "{c1}" "{c3} < RAM:PIPE$$$ {c4} {c5}" "" "" "" "" "" "" "" "" "" "DoIt" 27 skip END 28 endif 29 if "{c7}" EQ "" 30 execute PIPE "{c1}" "{c3} < RAM:PIPE$$$ {c4} {c5} {c6}" "" "" "" "" "" "" "" "" "" "DoIt" 31 skip END 32 endif 33 if "{c8}" EQ "" 34 execute PIPE "{c1}" "{c3} < RAM:PIPE$$$ {c4} {c5} {c6} {c7}" "" "" "" "" "" "" "" "" "" "DoIt" 35 skip END 36 endif 37 if "{c9}" EQ "" 38 execute PIPE "{c1}" "{c3} < RAM:PIPE$$$ {c4} {c5} {c6} {c7} {c8}" "" "" "" "" "" "" "" "" "" "DoIt" 39 skip END 40 endif 41 if "{ca}" EQ "" 42 execute PIPE "{c1}" "{c3} < RAM:PIPE$$$ {c4} {c5} {c6} {c7} {c8} {c9}" "" "" "" "" "" "" "" "" "" "DoIt"