[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: command for checking executability



On Mon, Nov 24, 2008 at 06:46:51PM -0800, Kelly Clowers wrote:
> On Mon, Nov 24, 2008 at 18:03, Can-Hua Chen <chencanhua@fudan.edu.cn> wrote:
> > hi, I am writing a bash script, and need a way (preferably a
> > shell command) to check whether a binary file can run on
> > the platform before hand.
> 
> I think you could do this with file or readelf, although I am not
> sure if this is the best way.
> 
> file /bin/cp
> /bin/cp: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
> dynamically linked (uses shared libs), for GNU/Linux 2.6.8, stripped
> 
> 
> readelf -h /bin/cp
> ELF Header:
>   Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
>   Class:                             ELF32
>   Data:                              2's complement, little endian
>   Version:                           1 (current)
>   OS/ABI:                            UNIX - System V
>   ABI Version:                       0
>   Type:                              EXEC (Executable file)
>   Machine:                           Intel 80386

And to complement/complicate that:

$ file /usr/bin/firefox
/usr/bin/firefox: symbolic link to `../lib/iceweasel/iceweasel'

$ file /usr/bin/iceweasel
/usr/bin/iceweasel: symbolic link to `../lib/iceweasel/iceweasel'

$ file /usr/lib/iceweasel/iceweasel
/usr/lib/iceweasel/iceweasel: POSIX shell script text executable

If you examine it carefully, you'll notice it will eventually run:

$ file /usr/lib/iceweasel/firefox-bin
/usr/lib/iceweasel/firefox-bin: symbolic link to `../xulrunner-1.9/xulrunner-stub'

$ file /usr/lib/xulrunner-1.9/xulrunner-stub
/usr/lib/xulrunner-1.9/xulrunner-stub: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, stripped

-- 
Tzafrir Cohen         | tzafrir@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir@cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend


Reply to: