Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!think!ames!sun-barr!newstop!sun!imagen!qmsseq!pipkins From: pipkins@qmsseq.imagen.com (Jeff Pipkins) Newsgroups: comp.sys.ibm.pc Subject: Re: Redirection and piping Message-ID: <63@qmsseq.imagen.com> Date: 12 Dec 89 16:19:43 GMT References: <89345.110313MHS108@PSUVM.BITNET> Reply-To: pipkins@qmsseq.UUCP (Jeff Pipkins) Organization: QMS Inc., Mobile, Alabama Lines: 67 In article <89345.110313MHS108@PSUVM.BITNET> MHS108@PSUVM.BITNET (Mark Solsman) writes: > Can any one out there explain how to use the redirection and the pipeline >features with ms-dos? [...] I have a hard disk utility that makes you enter >the drive number from the keyboard. I would like to redirect the drive numbers >from another file, so that I could run that unattended [...]. A program that reads its input from stdin and writes it output to stdout is known as a filter. A pipe is an operating system method of linking several of these filters together like a chain of elephants, so that the output of one becomes the input of another. Example: C:\> echo A: | diskutil The echo program is not, strictly speaking, a filter because it does not take its input from stdin. Instead, it takes its input from its command line and merely writes that to stdout. The pipe symbol '|' says that the output (stdout) of the echo program is to be used as the input (stdin) of the diskutil program. NOTE that if the diskutil program reads its input directly from the keyboard or with a BIOS call, then it will not read the input from stdin and you will have to type the drive letter anyway. That's why this doesn't work as you would expect: C:\> echo Y | format c: (kids, don't try this at home...) Redirection is the act of specifying a file or device for stdin or stdout. For example: C:\> more type read.me | more But has a similar effect. The > symbol is used to redirect stdout. Note that stdin and stdout can be redirected to a device as well as a file: C:\> echo ^L >lpt2 Will send a form feed character to the printer on LPT2. So you might also try something like this: C:\> echo Y >yes.ans C:\> diskutil dir c:\ | find '' | sort >dirlist.c This line will do a directory of drive C:, throw away all lines that don't have '' on them, sort the lines (by name, ext) and write it to a file called dirlist.c. In other words, dirlist.c will contain a sorted list of the directories on drive C: You can view this list later by typing C:\> more