execl on a script file
Hi guys
I hope someone can help me with this little problem. How do I run a script from within a c program? I can run binary executables (ls for example). However, when I try to run my script I get the following error:
Error initializing: Incompatible with this kernel
My script looks like this:
#!/bin/sh
touch keffo
If I run it from a shell it creates the file keffo. I have done the fork and uses execl in my program. This is the code snippet that does that:
pid_t pid;
switch (pid = fork()){
case -1:
printf("Fork failed\n");
break;
case 0: // Child process
execl("/home/iasion/test", "test", (char * )0);
printf("exec failed\n");
exit(1);
break;
default:
// printf("Created subprocess\n");
break;
}
The file has read, write and execute permissions for everyone and is owned på iasion.
|