home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!mcsun!sunic!news.lth.se!d92bo
- From: d92bo@efd.lth.se (Bengt Oehman)
- Subject: Re: Can't use redirection ">" with EXEC call ???
- Message-ID: <1993Jan25.152808.10861@lth.se>
- Sender: news@lth.se
- Organization: Lund Institute of Technology, Sweden
- References: <C1Bo2x.K6s@DMI.USherb.CA>
- Date: Mon, 25 Jan 1993 15:28:08 GMT
- Lines: 31
-
- In article <C1Bo2x.K6s@DMI.USherb.CA> desrg00@DMI.USherb.CA (GUY DESROSIERS) writes:
- >
- > I trying to do something like that (under TP 6.0)
- >
- > Exec('c:\dos\xcopy.exe', 'b:*.* > result.txt');
- >
- > I want to redirect the output in a file (result.txt).
- > Exec doesn't seem to like redirection. Any idea what I
- > do wrong.
- >
- > Thanks in advance.
-
- To be able to use redirection, you have to start the command processor,
- i.e. command.com (or ndos.com, if you're using Norton DOS). This filename
- is set, with path and everything, in the environment variable 'COMSPEC'.
-
- So, you do like the following:
-
- Exec(GetEnv('COMSPEC'),'/c xcopy b:*.* >result.txt');
-
- When you specify the /c option, the command processor will execute the
- command given on the line, and then exit. With this approach, you don't
- have to give the full pathname to xcopy, since command.com automatically
- searches your PATH. The trouble is that you can't get the return codes
- from xcopy, only the exitcode from command.com.
-
- -------
- Bengt Oehman, studying at Lund Institute of Technology, Sweden
- email: d92bo@efd.lth.se
-
-
-