⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tpipe.shar

📁 speech signal process tools
💻 SHAR
字号:
#! /bin/sh# This is a shell archive.  Remove anything before this line, then unpack# it by saving it into a file and typing "sh file".  To overwrite existing# files, type "sh file -c".  You can also feed this as standard input via# unshar, or by typing "sh <file", e.g..  If this archive is complete, you# will see the following message at the end:#		"End of shell archive."# Contents:  Makefile README tpipe.1 tpipe.c# Wrapped by rsalz@papaya.bbn.com on Thu May  3 16:40:10 1990PATH=/bin:/usr/bin:/usr/ucb ; export PATHif test -f 'Makefile' -a "${1}" != "-c" ; then   echo shar: Will not clobber existing file \"'Makefile'\"elseecho shar: Extracting \"'Makefile'\" \(107 characters\)sed "s/^X//" >'Makefile' <<'END_OF_FILE'XCC =		ccXCFLAGS =	-OXTPIPE =		tpipeXCFILES =	tpipe.cXX$(TPIPE): $(CFILES)X	$(CC) $(CFLAGS) $(CFILES) -o $@END_OF_FILEif test 107 -ne `wc -c <'Makefile'`; then    echo shar: \"'Makefile'\" unpacked with wrong size!fi# end of 'Makefile'fiif test -f 'README' -a "${1}" != "-c" ; then   echo shar: Will not clobber existing file \"'README'\"elseecho shar: Extracting \"'README'\" \(2118 characters\)sed "s/^X//" >'README' <<'END_OF_FILE'X-------------------------------------------------------------Xtpipe --  replicate standard output to an additional pipelineX              version 1.02    6 Mar. 1990X-------------------------------------------------------------XXtpipe is a simple utility program that can be used to split a unixXpipeline into two pipelines. That is, the output of one pipeline canXbe replicated and supplied as the input to two other pipelinesXexecuting simultaneously.XXLike tee(1), tpipe transcribes its standard input to its standardXoutput. But where tee(1) writes an additional copy of its input to aXfile, tpipe writes the additional copy to the input of anotherXpipeline, which is specified as the argument to tpipe. In a typicalXuse, this pipeline will eventually write to a file. The standardXoutput of tpipe is typically piped into another pipeline, whose outputX(if any) may go to the user's terminal or anywhere at all.XXI wrote tpipe because I was processing image files (using pbmplus),Xand I wanted to apply more than one pipeline to the same input file,Xbut the early parts of the pipeline were the same. I did not want toXhave to execute the early parts multiple times. I did not have enoughXdisk space to write what would have been a huge intermediate file.XFrankly, I did not know about teeing to named pipes, but anyway it'sXnice not to have to bother with them or worry about name conflicts,Xespecially if you have more than one job wanting to do this at theXsame time...XXSee the manual page for tpipe(1) for information about its use,Xincluding an artificial example. XXThis distribution contains four files:X  Readme (this is it)X  Makefile (it is trivial)X  tpipe.1  (the manual page)X  tpipe.c  (the code!)XXTo read the manual page, just `nroff -man tpipe.1'.XXTo compile tpipe, just `make'. Put tpipe.1 in the man1/ directory inXyour MANPATH or the system man path.XX--XDavid B Rosen, Cognitive & Neural Systems                  rosen@bucasb.bu.eduXCenter for Adaptive Systems                 rosen%bucasb@{buacca,bu-it}.bu.eduXBoston University              {mit-eddie,harvard,uunet}!bu.edu!thalamus!rosenEND_OF_FILEif test 2118 -ne `wc -c <'README'`; then    echo shar: \"'README'\" unpacked with wrong size!fi# end of 'README'fiif test -f 'tpipe.1' -a "${1}" != "-c" ; then   echo shar: Will not clobber existing file \"'tpipe.1'\"elseecho shar: Extracting \"'tpipe.1'\" \(2465 characters\)sed "s/^X//" >'tpipe.1' <<'END_OF_FILE'X.TH TPIPE 1  "29 January 1990"X.\" @(#)tpipe.1 1.0 90/01/29; David B Rosen (rosen@bucasb.bu.edu)X.SH NAMEXtpipe \- replicate the standard output into an additional pipelineXthat is run in a subshellX.SH SYNOPSISX.B tpipeX[X.I pipelineX]X.IX  "tpipe command"  ""  "\fLtpipe\fP \(em copy standard output to many pipelines"X.IX  "copy" "standard output to many pipelines \(em \fLtpipe\fP"X.IX  "standard output"  "copy to many pipelines"  ""  "copy to many pipelines \(em \fLtpipe\fP"X.IX  pipelines  "copy standard output to many"  ""  "copy standard output to many \(em \fLtpipe\fP"X.SH DESCRIPTIONX.B tpipeXtranscribes the standard input to theXstandard output and simultaneously writes an additional copy toXa specifiedX.IR pipeline .X.PPXtpipe is similar to tee(1) except that tpipe writes the duplicate copyXof its standard input to a command or pipeline instead of a file. ThisXcan help you avoid re-executing earlier commands in the pipeline,Xwriting temporary files, or resorting to the use of named pipes.X.PPXThe specifiedX.IR pipelineXis always executed in a subshell by sh(1), regardless of your currentXshell.  If a non-empty string is supplied as the argument, it must be Xa valid pipeline or command for sh(1). Normally, you will want to encloseXtheX.IR pipelineXargument in quotes ('' or "").  The type of quotes you chooseXwill affect variable substitution by your shell (see the man page Xfor your shell, such as csh(1), for details).X.PPXIf the subshell pipeline writes to its standard output, this outputXwill go to the standard output of tpipe, where it will be interspersedXin an unpredictable way with the other copy of standard input.XNormally, this is not what you want. Instead, you would typicallyXspecify a subshellX.IR pipeline Xwhose output is redirected to a file (as in the exampleXbelow) or has some other effect.X.SH EXAMPLEX.IPX% cmd1 <infile | tpipe "cmd2 | cmd3 >outfile" | cmd4 X.PPXwhich has the effect of running the output of command cmd1Xsimultaneously through two pipelines, "cmd2 | cmd3 >outfile" and cmd4.XDiagramatically, in this example (this will look wrong withXa variable-spaced font):XX.nfX                     --> cmd2 --> cmd3 --> outfileX                   /Xinfile  --> cmd1 -<X                   \\X                     --> cmd4 -->  (standard output)X.fiX.SH SEE ALSOX.BR tee (1),X.BR sh (1),X.BR cat (1)XX.SH AUTHORXDavid B RosenX.PPXTHIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT EXPRESS OR IMPLIED WARRANTY.END_OF_FILEif test 2465 -ne `wc -c <'tpipe.1'`; then    echo shar: \"'tpipe.1'\" unpacked with wrong size!fi# end of 'tpipe.1'fiif test -f 'tpipe.c' -a "${1}" != "-c" ; then   echo shar: Will not clobber existing file \"'tpipe.c'\"elseecho shar: Extracting \"'tpipe.c'\" \(1603 characters\)sed "s/^X//" >'tpipe.c' <<'END_OF_FILE'X/* tpipe.c -- tee a pipeline into two pipelines. Like tee(1) but X   argument is a command or pipeline rather than a file.XX   See the man page tpipe(1) supplied with this software.XX   This version uses the unix system calls popen(3), read(2), andX   write(2).  It uses write(2) to write directly to the fileno() ofX   of the file pointer stream returned by popen.XX   I've tried it out under BSD, System V, and an older version of unix,X   but:XX   THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT EXPRESS OR IMPLIED X   WARRANTY.XX   Version 1.02 (4 Mar 1989) (Use fileno())XX--XDavid B Rosen, Cognitive & Neural Systems                  rosen@bucasb.bu.eduXCenter for Adaptive Systems                 rosen%bucasb@{buacca,bu-it}.bu.eduXBoston University              {mit-eddie,harvard,uunet}!bu.edu!thalamus!rosenXX*/XX#include <stdio.h>XX/*#define NOHACK*/XX#ifndef BUFSIZX#define BUFSIZ 2048X#endif /*BUFSIZ*/XXint main(argc, argv)X     int argc;X     char *argv[];X{X  char buf[BUFSIZ];X  register FILE *subpipeline = NULL;X  register unsigned n;XX  if (argc == 2){X    if (*argv[1]) {X      if ((subpipeline = popen(argv[1],"w")) == NULL) {X	fprintf(stderr, "%s: can't create subpipeline %s\n", argv[0], argv[1]);X	exit(1);X      }X    }X  } else if (argc > 2) {X    fprintf(stderr, "usage: %s [pipeline]\n", argv[0]);X    exit(2);X  }XX  while ((n = read(0, buf, BUFSIZ)) > 0) {X    write(1, buf, n); /* write to standard output */X    if (subpipeline) {  /* write to subpipeline: */X      write((int)fileno(subpipeline), buf, n);X    }X  }XX  if (subpipeline) pclose(subpipeline);X  return 0;X}END_OF_FILEif test 1603 -ne `wc -c <'tpipe.c'`; then    echo shar: \"'tpipe.c'\" unpacked with wrong size!fi# end of 'tpipe.c'fiecho shar: End of shell archive.exit 0exit 0 # Just in case...-- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.Use a domain-based address or give alternate paths, or you may lose out.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -