🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.programmer
Article #1444

Re: Redirecting output of DOS batch files

#1444
From: Austin H. Ziegler, III
Date: Sun, 04 Mar 1990 13:33
38 lines
1992 bytes
>>>>> On 2 Mar 90 22:57:35 GMT, floyd@starsend.UUCP (Floyd Miller) said:

Floyd> I have a few batch files that run pipelined programs,
Floyd> searching for a pattern, extracting fields and sorting.
Floyd> They make life a bit easier by elliminating the need
Floyd> to retype long command lines.

Floyd> However, sometimes I want to run the final output through
Floyd> a pager (like "more") or save the results in a file.
Floyd> I try to run:  filter.bat | more
Floyd> More doesn't do anything.
Floyd> So I try:      filter.bat > f.out
Floyd> f.out gets created with no data while the output
Floyd> of filter.bat comes pouring out on my screen.

Floyd> Apparently, REDIRECTING DOESN'T WORK ON BATCH FILES.

	Not in the way that you are trying to do it.  MS-DOS sees
filter.bat | more as 
%0         %1 %2

	Thus in your batch file you would have to mark everything with
%1 and %2.  Unfortunately, you would have to have the redirection symbol
and the target in fixed positions.  The command line can handle most other
redirection that goes to stdout/stderr, but it cannot handle it in batch
files because it is trying to treat the pipe/redirection portions as
parameters.  An example might be:

FILTER.BAT
rem Show how redirection can be used in a batch file.
echo This is a test message. %1 %2
copy filter.bat nul %1 %2

Now this is a stupid example, but it shows that batch files *can* do
redirection, you have to do the redirection information by hand.

hope that helps,
austin
Technical Details
Message-ID: <AUSTIN.90Mar4083346@bucsf.bu.edu>
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!purdue!bu.edu!bucsf.bu.edu!austin
References: <0019@starsend.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!purdue!bu.edu!bucsf.bu.edu!austin
From: austin@bucsf.bu.edu (Austin H. Ziegler, III)
Newsgroups: comp.sys.ibm.pc.programmer
Subject: Re: Redirecting output of DOS batch files
Message-ID: <AUSTIN.90Mar4083346@bucsf.bu.edu>
Date: 4 Mar 90 13:33:46 GMT
References: <0019@starsend.UUCP>
Sender: news@bu.edu.bu.edu
Organization: Boston University College of Engineering
Lines: 38