shell in programs
mike at bria.UUCP
mike at bria.UUCP
Sat Jan 12 22:18:50 AEST 1991
In article <!_P+_!_ at irie.ais.org> 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 ..."
More information about the Comp.unix.questions
mailing list