State script on startup


Hello all

I have a script to init the can bus for IoT card.
This script is stored to /home/root on my board.

What is the best way to run on startup ?
Can I do that from my app?



I am using popen, WIFEXITED to execute my shell script from my App. below is the sample code for your reference but i don’t know whether it is best practice or not. If someone know better way please share with us

char line[256];
FILE* fp = popen(" 2>&1", "r");  //2>&1 redirect stderr to stdout//

while (fgets(line, sizeof(line), fp) != NULL)
    LE_INFO(" output: %s", line);

int result = pclose(fp);
LE_FATAL_IF(!WIFEXITED(result), "Could not run");
const int exitCode = WEXITSTATUS(result);
LE_FATAL_IF(exitCode != 0, " failed with exit code %d", exitCode);



Thank work fine.
I have added the script in the .adef file too (with bundel …)