The program I want to use in my code is a command line tool.
Users type ./program
first, and then users can use some command provided by the program.
I want to execute two commands in my source code (myCode.cpp
):
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int i;
printf ("Checking if processor is available...");
if (system(NULL)) puts ("Ok");
else exit (EXIT_FAILURE);
printf ("Executing command ...\n");
system ("./program");
system ("command1");
system ("command2");
return 0;
}
After execute my program(./myCode
), the program is launched but the two command is not executed.
How to execute the two commands?
How to terminate the program and then execute the following lines of my code? (after system()
)