executing python code

Mike Meyer mwm at mired.org
Fri Nov 5 21:25:21 EST 2004


mfuhr at fuhr.org (Michael Fuhr) writes:

> Darren Dale <dd55 at cornell.edu> writes:
>> Yes, I did chmod, the script is in the current directory.
>> $ mycode.py
>> bash: mycode.py: command not found
>>
>> I just tried:
>> $ ./mycode.py
>> and that will execute.
>
> That means the directory isn't in your PATH environment variable,
> neither as a full path (/path/to/the/directory) nor as ".", which
> means the current directory.  For security reasons it's usually
> wise to leave "." out of your PATH, so if you don't want to type

Actually, those reasons relate to having "." early in your path. If
it's the last thing on your path, you won't trigger any trojan horses.

> ./mycode.py each time then put your scripts in a directory that
> PATH knows about.  As others have mentioned, a common place for
> a user's private scripts is in ~/bin, that is, the "bin" directory
> under your home directory.  If it doesn't exist then you can use
> mkdir to create it, and if it's not in your PATH then you'll need
> to add it.

I find that symlinking ~/src/python/mycode.py to ~/bin/mycode means I
get to invoke it without having to specify the extension, and don't
have to reinstall the file if I change it.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list