Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!cernvax!chx400!ugun2b!ugsc2a!fisher From: fisher@sc2a.unige.ch (Markus Fischer) Newsgroups: comp.sys.ibm.pc Subject: Re: Redirection and piping Message-ID: <151@sc2a.unige.ch> Date: 13 Dec 89 12:19:48 GMT References: <89345.110313MHS108@PSUVM.BITNET> Organization: University of Geneva, Switzerland Lines: 61 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. Any help would be > greatly appreciated! Well, basically, you have the output redirect ('>' and '>>'), the input redirect ('<'), and the pipe ('|'). The redirect is used to send the output of a program to a file ('>' rewrites and '>>' appends), or to get the input from a file. This works only for programs that use standart i/o. Neither direct keyboard read, nor direct video addressing can be redirected; this applies to the pipe, also. The pipe is used when you want the output of a program to be send as the input to another. Basically, you could say that ...> foo | bar expands to ...> foo > tmp_file ...> bar < tmp_file ...> del tmp_file where the tmp_file is some unique non-existing filename, provided by DOS. As for you example, let's say you want to run Norton's SD (speed disk). This program requires you to enter a drive letter (as in you example), the default being the default current drive, followed by a . So you simply create a file containing the drive letter and a , let's call it drive.txt, and type: ...> SD < drive.txt or, if you prefer not to have this file always in you disk, type: ...> echo C | SD which will create the needed temporary file for you. NOTE: you will need to reboot afterwards, as SD requires you to type one last key *after* the job is done. As the program traps the keyboard (to avoid an unexpected end, messing up the disk), the buffer will be flushed before asking for that last character, or it will be read directly from the keyboard, which you can no longer do... It is of course possible to create more complex input files, for example for an editor... (which uses standard input ! most do not...) I have even written a simple program, called `write', which works a little like the `echo' command, but with more options. For example, ...> write C$_Y$_exit$_ produces a file containing: C Y exit But be warned: when unsing a pipe, the program will run with the file being it's only input! You can no longer answer to unexpected questions, nor can you type that last character after the "All done, strike any key to return to DOS"... So you better try everything out when you can harmlessly reboot any time! Hope this helps Markus Fischer -|--|--|--|--|--|--I Department of Anthropology -|--|--|--|--|--|--|-(#)-I University of Geneva -|--|--|--|--|--|--|--|--|-(#)-|-(#)(#)(_)-I CH-1227 Carouge (GE) -&-(_)-|--|--|-(#)-&--|-(#)(#)(_)(#)-&-(_)(#)-I Switzerland -|--|--|--|--|-(#)(_)-|-(_)(_)(_)(#)-I black (#) to kill ! --|--|-(#)(_)(_)(_)(#)(#)(_)(_) fisher@sc2a.unige.ch =+==+==+==+==+==+==+==+==+==+==+==+==+==+==+=(#)=+ fisher@cgeuge52.bitnet