navin_agrawal
asked on
executable file
In a C program, How it is possible to know that a particular file is executable?
It depends on your OS. Which OS do you use?
That's always the case for a EXE
ASKER
Let me be specific in telling the things. Following assumptions are made:
OS: Unix
File Name: /usr/home/stc/friend
Language: C
main ()
{
char file_name[][] = "/usr/home/stc/friend"
Here I want to know whether the file in file_name variable is executable or not. How to do this?
} /* end of mail () */
OS: Unix
File Name: /usr/home/stc/friend
Language: C
main ()
{
char file_name[][] = "/usr/home/stc/friend"
Here I want to know whether the file in file_name variable is executable or not. How to do this?
} /* end of mail () */
You'll have more luck posting in the UNIX Programming topic area.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if filename then you could use command line arguments since the first argument is the filename. Then you could use strtok or strstr to point to the "." and pull in the extension.
if structure, then my reference says that the first word of an executable file should be EXE program identifier. It lists this value as being 5A4DH. It's not clear to me if this is a sample value or always the case.
Matt