Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!mips!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!umriscc!mcs213f.cs.umr.edu!bkirby From: bkirby@mcs213f.cs.umr.edu (Bill Kirby) Newsgroups: comp.lang.pascal Subject: Re: Redirecting Exec() output Message-ID: <2684@umriscc.isc.umr.edu> Date: 27 Apr 91 07:57:51 GMT References: <26614@adm.brl.mil> Sender: news@umriscc.isc.umr.edu Organization: University of Missouri - Rolla Lines: 49 In article <26614@adm.brl.mil> nate@neutron.lcs.mit.edu writes: >Craig, > > If you use the CRT unit, then redirection will not work >unless you do: > > assign(output,''); > rewrite(output); >i. >(ignore i. above) > > ... > close(output); > > This might be an answer... I have not tried it. > >good luck... nate liskov I posted a reply to the original question, but I have not seen it here yet. I am having the same problem. In any case, the above code is not relevant to our problem. Yes, you need to open the file as described above if you want your pascal program to output to standard out. We want to Exec a program from within pascal and have the output redirected to a file. For instance, suppose I have a program HELLO.EXE (not necessarily written in pascal) which outputs "hello, world" to standard out. At the DOS prompt I can type "HELLO > OUTPUT.TXT" and a file OUTPUT.TXT will be created containing the text "hello, world". Now, if you try the following from within a pascal program: Exec("COMMAND.COM","/C HELLO.EXE > OUTPUT.TXT"); it should produce the exact same results, but it doesn't. Redirecting INPUT in this manner works fine. Am I doing something wrong? BTW, I'm using Turbo 6.0. Thanks, +--------------------------+-----------------------------------------------+ | Bill Kirby | Internet: bkirby@cs.umr.edu | | Computer Science Dept. | Bitnet: bkirby%cs.umr.edu@umrvmb.bitnet | | University of MO - Rolla | UUCP: ...!uunet!cs.umr.edu!bkirby | | Rolla, MO 65401 | | +--------------------------+-----------------------------------------------+