home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- 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
- From: hassink@cs.UAlberta.CA (Hassink Brian John)
- Subject: Re: Executing DOS commands in C
- Message-ID: <hassink.721710814@manning>
- Sender: news@cs.UAlberta.CA (News Administrator)
- Nntp-Posting-Host: manning.cs.ualberta.ca
- Organization: University of Alberta, Edmonton, Canada
- References: <1992Nov13.105428.6349@gw.wmich.edu>
- Date: Sat, 14 Nov 1992 03:13:34 GMT
- Lines: 28
-
- 832root@gw.wmich.edu writes:
-
- >Is there a relatively simple way in C to have a program execute an
- >external command (for instance 'dir'), and have it direct the output
- >to where ever the program's output is going?
-
- >I'm using DCC and WB2.04.
-
- I wrote a bunch of little routines to let me substitute unix commands
- for the amiga dos equivalents.
-
- So I can do things like "rm fu.bar" instead of "delete fu.bar".
-
- All I did was write a C program that takes the filename as an argument,
- and then append this filename to the string "delete ".
-
- strcpy (command,"delete ");
- strcat (command,argv[1]);
- system (command);
-
- The "system" statement will execute the contents of the command string as
- though you were typing it on the CLI command line.
-
- Hope it helps.
-
- Brian
- hassink@cs.ualberta.ca
-
-