On Tue, Nov 25, 2008 at 10:03:08AM +0800, Can-Hua Chen 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.

-x will tell you whether you have execute permissions for the file (or
directory), if that's what you're looking for.  If you mean that you
want to check CPU architecture, binary compatibility, etc., your best
bet would probably be to somehow parse the output of the 'file' command.

$ if [ -x /etc/inetd.conf ] ; then echo "executable" ; else echo "not 
executable" ; fi ;
not executable

$ if [ -x /bin/bash ] ; then echo "executable" ; else echo "not executable" ; 
fi ; 
executable

-- 
Dave Sherohman
NomadNet, Inc.
http://nomadnetinc.com/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to