home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20099 < prev    next >
Encoding:
Text File  |  1993-01-23  |  2.2 KB  |  56 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!usenet-feed.umr.edu!mcastle
  3. From: mcastle@cs.umr.edu (Michael R Castle)
  4. Subject: Re: Help with spawnl() function
  5. References: <yT7JXB3w164w@jaflrn.UUCP> <TskPXB3w165w@wozzle.linet.org>
  6. Date: Sat, 23 Jan 1993 01:40:06 GMT
  7. Nntp-Posting-Host: next8.cs.umr.edu
  8. Organization: University of Missouri - Rolla, Rolla, MO
  9. Sender: cnews@umr.edu (UMR Usenet News Post)
  10. Message-ID: <1993Jan23.014006.2642@umr.edu>
  11. Lines: 43
  12.  
  13. In article <TskPXB3w165w@wozzle.linet.org> alane@wozzle.linet.org (J. Alan Eldridge) writes:
  14. >jaf@jaflrn.UUCP (Jon Freivald) writes:
  15. >
  16. >> Why not use remove() or unlink()?  You can't do "system("del file")
  17. >> because del (& erase) are internal commands, although you could do
  18. >> "system("command /c del file")" [a consideration here - what about folks
  19. >> who don't use command.com?  It's no-where on my machine, and which
  20. >> command processor I'm using depends on what mood I'm in..!]
  21. >
  22. >char szCmdbuf[ 130 ];
  23. >char *szComspec=getenv("COMSPEC");
  24. >
  25. >if (!szComspec)
  26. >    szComspec="COMMAND.COM";
  27. >sprintf(szCmdbuf, "%s /C del file", szComspec);
  28. >system(szCmdbuf);
  29.  
  30. From my turbo-c++ 1.00 manual:
  31.  
  32. _system_ invokes the DOS COMMAND.COM file to execute a DOS command, batch 
  33. file, or other program named by the string command, from inside an executing 
  34. C program. 
  35.  
  36. To be located and executed, the program must be in the current directory
  37. or in one of the directories listed in the PATH string in the environment.
  38.  
  39. The COMSPEC envrionment variable is used to find the COMMAND.COM file, so 
  40. that file need not be in the current directory.
  41.  
  42. Copyright 1990 by Borland International.  Reprinted without permission.
  43.  
  44. Now, if borland did it right, it will use whatever is in COMSPEC, be it
  45. 4dos, ndos, or whatever.  The problem will then be, does your shell
  46. support that command internally?  If not, is there an executable or 
  47. batch file that does?
  48.  
  49. regards,
  50. mrc
  51. -- 
  52. Mike Castle .-=NEXUS=-.  Life is like a clock:  You can work constantly
  53.   mcastle@cs.umr.edu     and be right all the time, or not work at all
  54. S087891@UMRVMA.UMR.EDU   and be right at least twice a day.  -- mrc
  55.     We are all of us living in the shadow of Manhattan.  -- Watchmen
  56.