Reputation: 1086
I'm trying to execute a binary file named "helloworld" (compiled from a source.c) located in another directory with my program notify.c. Here's where my files are located:
/home/morts/Desktop/helloworld
/home/morts/Desktop/Homeworks/notify
I tried with:
const char *cmd = "/home/morts/Desktop/helloworld";
execl(cmd, "LOL", NULL);
perror("execl()");
exit(EXIT_FAILURE);
but I get:
execl(): Permission denied
If helloworld would be located in the same directory of notify, I'd simply put "./helloworld", but since they are in different directories, how can I fix this?
Thanks and regards.
Upvotes: 3
Views: 8036
Reputation: 96
if you want to execute an file hello under path /bin/test by execl without any parameters try following:
execl("/bin/test/hello", "hello", (char*)NULL);
Check following otherwise you may get a permission denial error:
/path/your_file
without any spaceUpvotes: 1
Reputation: 10698
You should check that the path is correct and you have the right permissions to execute this file by trying to run the command directly in the terminal :
/home/morts/Desktop/helloworld
If it works then you have to check that the user running your program also have the permission to execute that file.
Upvotes: 0