Link to home
Start Free TrialLog in
Avatar of navin_agrawal
navin_agrawal

asked on

executable file

In a C program, How it is possible to know that a particular file is executable?
Avatar of MatthewL
MatthewL

Are you just interested in the actual file name or the file structure?

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
It depends on your OS. Which OS do you use?
That's always the case for a EXE
Avatar of navin_agrawal

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 () */
You'll have more luck posting in the UNIX Programming topic area.
ASKER CERTIFIED SOLUTION
Avatar of rbr
rbr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial