executable files w/o using 'file'

executable files w/o using 'file'

Post by Tao Fan (ext 2 » Tue, 02 May 1995 04:00:00



Hi,

any one knows if there is a way to find out if a file is excutable
without using the command 'file'?

I don't mean just simply accessing the status info and look at the
file mode.  Is there a c function or some sort that can actually
enable us to know if the file is executable.

Tao.

ps.  executable doesn't include script files.

Thanks in advanced.

 
 
 

executable files w/o using 'file'

Post by Dave Plon » Wed, 03 May 1995 04:00:00



Quote:> Hi,
> any one knows if there is a way to find out if a file is excutable
> without using the command 'file'?
> I don't mean just simply accessing the status info and look at the
> file mode.  Is there a c function or some sort that can actually
> enable us to know if the file is executable.

No,  you have to do what the file command does, which is to read a
small portion of the beginning of the file, and guess what type of
file it is.  For executables, different versions of Unix have a
different "magic numbers", as they are called, at a specific byte
offset in the file.
There's no portable way to tell.  (FYI, IBM's AIX can't even tell
the difference between an executable and an object file - they have
the same magic number.)

See the file /etc/magic or the magic man page if you have one.

Hope this helps,
Dave

BTW, email failed (for obvious reasons):
   ----- Transcript of session follows -----
   550 droopy (tcp)... Host unknown

--
------------------------------------------------------///--------------------
  Dave Plonka  ARS:N9HZF          Amiga - 68040 -    ///  486DLC-33 running

- Lead Systems Programmer, McHugh Freeman ------- \\X/- Waukesha, Wisconsin -

 
 
 

1. executable files w/o using 'file'

Hi,

is there any way of telling whether if a file is executable or not without
using the "file' command?  Actually I am looking for a c routine that
can actually do this.  by excutable I don't mean script files.  

and looking at the status structure and saying that the mode is executable
does not mean that the file is an executable file.

Thanks in advanced.

Please send mail to:

2. Cannot connect my news server

3. 'cat file' but only if 'file' exist

4. Need help with spooler / printer configuration

5. Coverting '.so' files to '.o' files

6. Update NBD URL in documentation.

7. File size of 'tmp' files for 'vi'

8. change video resolution

9. "rm: can't unlink 'files'",can't delete files

10. How do I write an executable 'batch' file

11. Executable Binary File vs. Executable Script File

12. Can't 'Open With...' HTML Konq file manager using Opera 6 beta 1

13. OpenWin Filemgr: 'cannot open file: too many files open' ?