bruceb@amiga.UUCP (Bruce Barrett) (02/26/86)
Tony Sumrall pointed out that he only got 42 lines of the pipe posting.
When I went to sent him my saved copy of the posting I realized I had only
received 42 lines too. So we'll try again.
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 "?"
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.
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.
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 used 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.
Lines 12-15, What to do if we never find the "|" character, and
run out of parameters looking for it.
Lines 16-48, We've found the "|" character so let's call our self
once more eliminating any "stray" parameters.
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"
43 skip END
44 endif
45 else
46 execute PIPE "{c1} {c2}" "{c3}" "{c4}" "{c5}" "{c6}" "{c7}" "{c8}" "{c9}" "{ca}" "{cb}" "" "is|?"
47 SKIP END
48 endif
49 endif
50
51 if "{FLAG}" eq "DoIt"
52 {c1}
53 {c2}
54 delete RAM:PIPE$$$
55 endif
56 LAB END