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

Re: script: test binary program vs shell script



All,

Jerome BENOIT <jgmbenoit@mailsnare.net>:
> in side a bash script, I would like to test is a given program is
> either a binary file or a script file: is there way to so ?

"file -iL" might be what you're looking for. "-i" for mime type output,
"-L" to follow symbolic links:

    % file -iL config.guess spamassassin unrar  
    config.guess: application/x-shellscript
    spamassassin: application/x-perl
    unrar:        application/x-executable, dynamically linked (uses shared \
    libs), stripped
    % 

Versus:

    % file -L config.guess spamassassin unrar 
    config.guess: Bourne shell script text executable
    spamassassin: perl script text executable
    unrar:        ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped
    % 

If no -L, then:

    % file spamassassin
    spamassassin: symbolic link to /usr/bin/spamassassin
    % 

Eric
--
Eric De Mund   | Ixian Systems           | Jab: eadixian@jabber.org/main
ead@ixian.com  | 650 Castro St, #120-210 | Y!M: ead0002
ixian.com/ead/ | Mountain View, CA 94041 | ICQ: 811788


Reply to: