The UNIX "file" command is not that reliable on its own, and certainly not reliably portable given that strings change with versions and Linux flavours. First a binary executable:
$ cp /bin/ls /tmp
$ ls -l /tmp/ls
-rwxr-xr-x 1 chrisw users 92072 Jun 3 08:11 /tmp/ls
$ file /tmp/ls
/tmp/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
# Remove execute permission
$ chmod a-x /tmp/ls
$ ls -l /tmp/ls
-rw-r--r-- 1 chrisw users 92072 Jun 3 08:11 /tmp/ls
$ file /tmp/ls
/tmp/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
# Same description but NOT executable
$ cp /bin/ls /tmp
$ ls -l /tmp/ls
-rwxr-xr-x 1 chrisw users 92072 Jun 3 08:11 /tmp/ls
$ file /tmp/ls
/tmp/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
# Remove execute permission
$ chmod a-x /tmp/ls
$ ls -l /tmp/ls
-rw-r--r-- 1 chrisw users 92072 Jun 3 08:11 /tmp/ls
$ file /tmp/ls
/tmp/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
# Same description but NOT executable
To copy to clipboard, switch view to plain text mode
Same problem with shell scripts.
$ ls -l /tmp/verifyCD.sh
-rwxr--r-- 1 chrisw users 611 Jun 3 08:06 verifyCD.sh
$ file /tmp/verifyCD.sh
/tmp/verifyCD.sh: Bourne-Again shell script text executable
# ^^ good ID, and file is executable
$ chmod a-x /tmp/verifyCD.sh
$ ls -l /tmp/verifyCD.sh
-rw-r--r-- 1 chrisw users 611 Jun 3 08:06 verifyCD.sh
$ file /tmp/verifyCD.sh
/tmp/verifyCD.sh: Bourne-Again shell script text executable
# Attempting to execute this will fail. Huh? ^^^
$ ls -l /tmp/verifyCD.sh
-rwxr--r-- 1 chrisw users 611 Jun 3 08:06 verifyCD.sh
$ file /tmp/verifyCD.sh
/tmp/verifyCD.sh: Bourne-Again shell script text executable
# ^^ good ID, and file is executable
$ chmod a-x /tmp/verifyCD.sh
$ ls -l /tmp/verifyCD.sh
-rw-r--r-- 1 chrisw users 611 Jun 3 08:06 verifyCD.sh
$ file /tmp/verifyCD.sh
/tmp/verifyCD.sh: Bourne-Again shell script text executable
# Attempting to execute this will fail. Huh? ^^^
To copy to clipboard, switch view to plain text mode
If the execute bit is set in the file permissions (and it is a regular file) then you should try to execute it. If the user has set the bit on something that is not executable then that, I believe, is the user's problem.
Bookmarks