Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bria!mike Newsgroups: comp.unix.questions Subject: Re: shell in programs Message-ID: <346@bria> Date: 12 Jan 91 11:18:50 GMT References: Reply-To: mike@bria.UUCP (Michael Stefanik) Distribution: na Organization: Briareus Corporation, Los Angeles, CA Lines: 22 In article ais.org!garath (Scott Grosch) writes: > > If I make a C program on this account, is there any way to have the >program execute a shell command if a certain part of the program is reached? > A quick and dirty way is to use the system() subroutine, ie: system("cp myfile yourfile"); Another way is to use the fork() exec() yourself, such as: if ( fork() ) wait(NULL); else execl("/bin/sh","sh","-c","cp myfile yourfile"); -- Michael Stefanik, Systems Engineer (JOAT), Briareus Corporation UUCP: ...!uunet!bria!mike -- technoignorami (tek'no-ig'no-ram`i) a group of individuals that are constantly found to be saying things like "Well, it works on my DOS machine ..."