Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!mtune!whuts!picuxa!gp From: gp@picuxa.UUCP (Greg Pasquariello X1190) Newsgroups: comp.lang.c Subject: Re: system Message-ID: <452@picuxa.UUCP> Date: 19 Jan 88 22:21:33 GMT References: <127@dcrbg1.UUCP> Organization: AT&T Information Systems, Parsippany NJ Lines: 17 Keywords: c program Summary: how to use system In article <127@dcrbg1.UUCP>, bcf2303@dcrbg1.UUCP (Wing Chow) writes: > > can someone give me an example of how to use 'system' in a c program? 'System()' is a way to call an external process from within your C code. The way you use it, is to pass it the process name e.g. system("ls -l"), or system("sh -c") or if your forced to be running DOS (:-)) system("command"); This will have the effect of stopping your program, executing the command, and returning control to your program. On a UNIX system this is (almost) equi- vilent to a: if(!fork()) execlp("/bin/sh","sh","-c",command,0); wait() Hope this helps. Greg Pasquariello