home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15825 < prev    next >
Encoding:
Text File  |  1992-11-14  |  1.3 KB  |  41 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!wupost!gumby!destroyer!cs.ubc.ca!alberta!hassink
  3. From: hassink@cs.UAlberta.CA (Hassink Brian John)
  4. Subject: Re: Executing DOS commands in C
  5. Message-ID: <hassink.721710814@manning>
  6. Sender: news@cs.UAlberta.CA (News Administrator)
  7. Nntp-Posting-Host: manning.cs.ualberta.ca
  8. Organization: University of Alberta, Edmonton, Canada
  9. References: <1992Nov13.105428.6349@gw.wmich.edu>
  10. Date: Sat, 14 Nov 1992 03:13:34 GMT
  11. Lines: 28
  12.  
  13. 832root@gw.wmich.edu writes:
  14.  
  15. >Is there a relatively simple way in C to have a program execute an
  16. >external command (for instance 'dir'), and have it direct the output
  17. >to where ever the program's output is going?
  18.  
  19. >I'm using DCC and WB2.04.
  20.  
  21. I wrote a bunch of little routines to let me substitute unix commands
  22. for the amiga dos equivalents. 
  23.  
  24. So I can do things like "rm fu.bar" instead of "delete fu.bar".
  25.  
  26. All I did was write a C program that takes the filename as an argument,
  27. and then append this filename to the string "delete ".
  28.  
  29. strcpy (command,"delete ");
  30. strcat (command,argv[1]);
  31. system (command);
  32.  
  33. The "system" statement will execute the contents of the command string as
  34. though you were typing it on the CLI command line.
  35.  
  36. Hope it helps.
  37.  
  38. Brian
  39. hassink@cs.ualberta.ca
  40.  
  41.