Need Simple Way To Determine If File Is Executable
Sebastian 'lunar' Wiesner
basti.wiesner at gmx.net
Thu Dec 21 07:15:44 EST 2006
Fredrik Lundh <fredrik at pythonware.com> schrieb
> Sebastian 'lunar' Wiesner wrote:
>
>>> you're confusing the shell's "is this file executable" check with
>>> the loader's "can I execute this file" check:
>>>
>>> $ export PATH=.:$PATH
>>> $ dd if=/dev/zero of=ls count=1
>>> 1+0 records in
>>> 1+0 records out
>>> $ ls -l ls
>>> -rw-rw-r-- 1 slab slab 512 Dec 20 03:33 ls
>>> $ chmod a+x ls
>>> $ ls
>>> -bash: ./ls: cannot execute binary file
>>
>> ???
>> Am I blind or is there really no difference between you shell example
>> an mine?
>> As far as I can see, you are doing exactly the same thing as I did...
>
> no, I'm showing that a local file marked as executable overrides a
> shared one, even if the local file isn't actually an executable.
Well, that doesn't tell us anything about, whether a file executable or
not.
But anyway: you admit, that the local file "ls" is __not__ actually
executable, although it has the x-bit set?
>> So what are trying to proof?
>
> that you're wrong when you claim that the contents of the file matters
> when using the usual Unix conventions to check if a file is
> executable.
Let me ask you a question:
[lunar at nargond]-[13:09:52] >> ~/test
--> cat test.sh
#!/bin/bash
if [ "$1" ]; then
echo "Hello $1"
else
echo "Hello world"
fi
[lunar at nargond]-[13:09:54] >> ~/test
--> ll test.sh
-rw-r--r-- 1 lunar lunar 76 2006-12-21 13:09 test.sh
Is test.sh now executable or not?
Bye
lunar
--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
More information about the Python-list
mailing list