Reputation:
Will I execute shell script .sh if I run code like this:
int system (char *s);
int sh_exec_ok; //Shell script execution flag
sh_exec_ok = system("something/script_name.sh");
What do you suggest me to use to execute shell scripts in C code?
Upvotes: 2
Views: 424
Reputation: 7374
Using system
is the right way to run a shell command. Some notes:
system
yourself. Instead, do #include <stdlib.h>
system(NULL)
. If the return value is non-zero, then a command processor to handle the system
function call is available.Upvotes: 2