Everhart,Glenn From: mathog@seqaxp.bio.caltech.edu Sent: Tuesday, March 31, 1998 6:15 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: PIPE, but no TEE? In article <3.0.5.32.19980331135822.00a0c350@osshe.edu>, Dan Sugalski writes: >At 06:51 PM 3/31/1998 GMT, mathog@seqaxp.bio.caltech.edu wrote: >>In OpenVMS 7.1 there is a PIPE, but no TEE. Will it be implemented in >>7.2 (or later)? If not, how do you do the equivalent of this: >> >>psx> make -f makefile | tee make_vms.com >> > >Hmmm. How 'bout this (off the top of my head, and not actually tested): > >/* tee.c - do a unix-style tee */ Thanks Dan, that was about 98% of the battle. Here is the version I think I'll use, which is similar to most Unix tee's in that it will split to many output files at once. It has been tested on OpenVMS 7.1, and works with: $ pipe dir/col=1 | tee f1.txt f2.txt f3.txt f4.txt f5.txt f6.txt f7.txt f8.txt f9.txt f10.txt and also (note the illegal filename) $ pipe dir/col=1 | tee f1.txt f~2.txt f3.txt 2>oops.err Although this version is wired for up to 20 output files, I only tested to 10. [Attention OpenVMS engineers - this function really should be part of PIPE so that we don't have to start another image just to split the output stream.] /* tee.c - do a unix-style tee From sugalskd@osshe.edu 31-MAR-1998 13:58:26.25 slightly modified to do up to 20 files */ #define MAXTFILES 20 #include #include void main(int argc, char *argv[]) { FILE *TeeFile[MAXTFILES]; char InputLine[4096]; int tcount,ocount; /* open the tee files */ for(tcount=1; argv[tcount] != NULL && tcount < MAXTFILES && tcount <=argc; tcount++){ TeeFile[tcount] = fopen(argv[tcount], "w"); if(TeeFile[tcount] == NULL){ fprintf(stderr,"tee to %s failed\n",argv[tcount]); } } tcount--; /* always comes out of the loop one too high */ /* grab lines until we have no more */ while (gets(InputLine)) { puts(InputLine); for(ocount=1; ocount<= tcount; ocount++){ if(TeeFile[ocount] != NULL){ fputs(InputLine, TeeFile[ocount]); fputc('\n', TeeFile[ocount]); } } } for(ocount=1; ocount<= tcount; ocount++){ if(TeeFile[ocount] != NULL){ fclose(TeeFile[ocount]); } } } Regards, David Mathog mathog@seqaxp.bio.caltech.edu Manager, sequence analysis facility, biology division, Caltech ************************************************************************** * Affordable VMS? See: http://seqaxp.bio.caltech.edu/www/pcvms.html * **************************************************************************