Hi,
I just tried to call a simple script from a pretty simple C program. I could not succeed a message was thrown saying
"sh: line 1: "Script name with path": Permission denied"
The C program and shell script are below, both are in the same directory and shell script is given full permission (chmod 777).
C Program :
#include <stdio.h>
#include <stdlib.h>
int main()
{
char script[10] = {'s','t','a','t','u','s'};
printf("\nWelcome to the new world ....\n");
system(script);
}
Shell Script : Name is "status"
clear
echo "sending mail ."
Let me know where the problem is. Thanks in advance
Regards,
Chanakya
Hi Porter,
Thanks for your quick reply but after adding #!/bin/bash also same error..
porter
4
Try the following
int i;
i=system("which status"); printf("i=%d\n",i);
i=system("status"); printf("i=%d\n",i);
i=system("./status"); printf("i=%d\n",i);
and while you are at it, post the result of
ls -ld status
Make sure your "staus" scripts should have execute permission as well as give the full path for system lib function
system(/your/path/staus)
Thanks a lor porter .... it WORKED !!!!!!!!! but here i just want to know why you asked me to check for "ls -ld status" ..
Sanjay,
I have already mentioned that status has execution permission..
-Chanakya
porter
7
Although you now say it worked, we don't know what you did. We're working blind here.
Porter,
I mean it worked with the code posted by you.
-Chanakya