Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpl-opus!hpcc05!hpyhde4!hpycla!hpcuhc!hpcupt3!defaria From: defaria@hpcupt3.cup.hp.com (Andy DeFaria) Newsgroups: comp.lang.pascal Subject: Re: Redirecting I/O for .BAT files? Message-ID: <45670022@hpcupt3.cup.hp.com> Date: 19 Jun 91 07:24:09 GMT References: <45670020@hpcupt3.cup.hp.com> Organization: Hewlett Packard, Cupertino Lines: 39 >/ hpcupt3:comp.lang.pascal / s9100202@giaea.gi.oz (Lee Hollingworth) / 11:05 pm Jun 17, 1991 / >To redirect output from a batch file, you must use the Command command. > >command /c FOO > OUT.DAT > >This would redirect the output from FOO.BAT to OUT.DAT. I was surprized that this does indeed work. Care to relate that in TP terms now? I thought that it would be easy, simply run a COMMAND.COM to run yet another COMMAND.COM with the /C flag and the output from a .BAT file would be redirected but it doesn't work: {$M 16384,0,0} Program Foo; Uses DOS; Begin { Foo } Exec ('D:\COMMAND.COM', 'D:\COMMAND.COM /C C:\ANDY\FOO.BAT > FOO.OUT'); Writeln ('DOSError = ', DOSError); End. { Foo } Where D:\COMMAND.COM is a valid COMMAND.COM and C:\ANDY\FOO.BAT contains: DIR When this is run I see: Specified COMMAND search directory bad DOSError = 0 written to the screen and in examining FOO.OUT I find simply: DOSError = 2 Now what am I doing wrong?