Selecting an application

Yates, Glen JAMES.G.YATES at saic.com
Wed May 7 13:42:00 EDT 2003


OK, I see that it is time for the definitive answer.
 
Yennie said:
>All these things considered, the only _true_ sign of an executable is the
executable flag on the file.
 
No, it only determines whether you have permission to execute the file or
not.
 
>When it really comes down to it, I can create any file with any name and
any extension,
> type in "chmod +x myFileName", and it will look just as executable as any
other file can.
 
Exactly!, which negates your first comment.

But there is a way to get at "application-style" executables, and that is by
using the "file" command, though the exact output will be somewhat
architecture dependent.
 
Here is its output on a 'C' program I just compiled:
 
a.out:         ELF 32-bit MSB dynamic executable (not stripped) MIPS -
version 1
 
And here is its output when run on the Metacard install script:
 
install.sh:     /bin/sh script text
 
So, you see it can be used to discriminate between "application-style"
executables and executable scripts. It can also attempt to determine file
types. I'll leave it as an exercise to the reader to determine how to parse
the output to determine if they have an executable or not, perhaps its the
existence of the word 'executable' or maybe 'ELF' but there are other
executable formats as well such as 'COFF'.
 
-Glen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.runrev.com/pipermail/metacard/attachments/20030507/c645546f/attachment.htm


More information about the metacard mailing list