Originally Posted by
manasij7479
Doesn't that only apply for those exec functions taking a file as the argument ? .and not a path for the binary ?
A path to a binary is a file path; a binary is a file. These are the same thing (note, the script must have a shebang indicating the interpreter and be marked as an executable, which shell scripts usually also are). There is not one loader* for execve and then some other loader for everything else, it is just that the "e" functions include an additional parameter (environment variables, which are also not just part of the shell, altho it is common to think of them in relation to shell access via globals).
Certainly this works fine:
Code:
#include <stdio.h>
#include <unistd.h>
int main(void) {
char *args[] = { "test.sh", NULL };
execv("/home/scripts/test.sh", args);
return 0;
}
You can try it with all the other "exec" functions too if you want...
* note this is not the same thing as the dynamic (library) loader potentially invoked for binaries after the kernel handler/loader has loaded the binary into memory and began its work.