Need Simple Way To Determine If File Is Executable

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Wed Dec 20 07:11:22 EST 2006


In <emav7p$e5f$03$1 at news.t-online.com>, Sebastian 'lunar' Wiesner wrote:

> Gabriel Genellina <gagsl-py at yahoo.com.ar> schrieb
>> A similar function exists on Linux too. But even if a file has the
>> right file format, if it does not have the execute bit set, won't run.
>> And you could set that bit on a JPG image too - and nothing good would
>> happen, I presume. 
> 
> Really? I don't think so. Afaik on Linux executable binary files need an
> ELF header.

There are other executable loaders for `a.out` and `COFF` in the kernel,
and with the `binfmt_misc` module you can make anything with a "magic"
header executable, including Python scripts/bytecode and even JPEG images.

  http://www.tat.physik.uni-tuebingen.de/~rguenth/linux/binfmt_misc.html

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list