changing a file's permissions

oscartheduck oscartheduck at gmail.com
Mon Oct 2 09:06:28 EDT 2006


> This is an attribute of the file (an object in the filesystem) which
> is checked by the kernel before allowing the file to be
> executed. Python has nothing to do with this; if the attributes allow
> execution, you can execute it as a program; if not, you can't.
>

I took this to heart and changed my question to "How do I run shell
commands within a python script?" I was taking my lead from Perl, which
has the infamous backquotes, and though the two languages differ in
conceptive aim, I discovered that shell commands are accessible in
python:

http://pyre.third-bit.com/pipermail/2005fall/2005-October/000228.html




> Incidentally, if the program is intended to be run from a command
> line, it's best to name the file with no '.py' extension. The fact
> that a command is implemented in Python is irrelevant to the person
> running that command; it also means you can implement it in some other
> language later on without changing everything that uses that command.

How I've been doing it inside my script (which is a script generation
tool, nicely enough) is creating symlinks with no extension on them in
a directory in $PATH that the user has read/write/execute access to.
It's a hidden directory inside the user's home folder that I added to
the end of the path.




More information about the Python-list mailing list