home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / pascal / 8520 < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.4 KB  |  43 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!mcsun!sunic!news.lth.se!d92bo
  3. From: d92bo@efd.lth.se (Bengt Oehman)
  4. Subject: Re: Can't use redirection ">" with EXEC call ???
  5. Message-ID: <1993Jan25.152808.10861@lth.se>
  6. Sender: news@lth.se
  7. Organization: Lund Institute of Technology, Sweden
  8. References: <C1Bo2x.K6s@DMI.USherb.CA>
  9. Date: Mon, 25 Jan 1993 15:28:08 GMT
  10. Lines: 31
  11.  
  12. In article <C1Bo2x.K6s@DMI.USherb.CA> desrg00@DMI.USherb.CA (GUY DESROSIERS) writes:
  13. >
  14. >    I trying to do something like that (under TP 6.0)
  15. >
  16. >    Exec('c:\dos\xcopy.exe', 'b:*.* > result.txt');
  17. >
  18. >    I want to redirect the output in a file (result.txt).
  19. >    Exec doesn't seem to like redirection. Any idea what I
  20. >    do wrong.
  21. >
  22. >    Thanks in advance.
  23.  
  24. To be able to use redirection, you have to start the command processor,
  25. i.e. command.com (or ndos.com, if you're using Norton DOS). This filename
  26. is set, with path and everything, in the environment variable 'COMSPEC'.
  27.  
  28. So, you do like the following:
  29.  
  30.   Exec(GetEnv('COMSPEC'),'/c xcopy b:*.* >result.txt');
  31.  
  32. When you specify the /c option, the command processor will execute the
  33. command given on the line, and then exit. With this approach, you don't
  34. have to give the full pathname to xcopy, since command.com automatically
  35. searches your PATH. The trouble is that you can't get the return codes
  36. from xcopy, only the exitcode from command.com.
  37.  
  38. -------
  39. Bengt Oehman, studying at Lund Institute of Technology, Sweden
  40. email: d92bo@efd.lth.se
  41.  
  42.  
  43.