Print
Parent Category: Development
Category: C / C++
Hits: 3776

Do you want to execute a shell script or shell command in ac program?

The Following is a simple c -program with the execution of a script:

#include <stdio.h>

int main (void)
{
    system ( "/path/to/your/script.sh" ) ;
    return 0;
}

The system () command runs a program or script from the system. "Here" you need to add the string to run your shell tool or script.

To compile your little program type in:

cd /path/to/program-folder

gcc -o output-filename source-filename.c

Then you get a c-file with your out-filename in you program folder.