Need Simple Way To Determine If File Is Executable
Gabriel Genellina
gagsl-py at yahoo.com.ar
Thu Dec 14 19:36:10 EST 2006
At Thursday 14/12/2006 19:21, John McMonagle wrote:
> > I have a program wherein I want one behavior when a file is set
> as executable
> > and a different behavior if it is not. Is there a simple way to determine
> > whether a given named file is executable that does not resort to all the
> > lowlevel ugliness of os.stat() AND that is portable across Win32 and *nix?
> >
>
>os.access(pathToFile, os.X_OK)
That won't work on Windows.
You have to define what do you mean by "a file is set as executable"
on Windows.
a.exe is executable and nobody would discuss that. I can supress the
extension and type simply: a, on the command line, and get a.exe
executed. Same for a.com
What about a.bat? cmd.exe is executed and runs the batch file. I can
even omit the extension. Is a.bat executable then?
What about a.py? Another process starts and handles the file
(python.exe). Is a.py executable then?
I can type a.mdb on the command prompt and launch an Access
application. Is a.mdb executable then?
If I type a.doc on the command prompt, Word is executed and opens
that file. Is a.doc executable then?
The answer may be so narrow to just consider .exe .com and a few
more, or so broad to consider all things that os.startfile can handle
without error.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
More information about the Python-list
mailing list