[Tutor] Looking for some guidance.
Roger Merchberger
zmerch at 30below.com
Thu Feb 5 15:17:59 EST 2004
Rumor has it that Joshua Banks may have mentioned these words:
>I've looked at the FAQ's and unless I've overlooked something, is there
>a preferred directory that I can store my Python scripts.
Nope. Stick 'em anywhere you want... ;-)
> I would like
>to have the ability to place the scripts somewhere where I have the
>ability to execute them from any directory that I happen to be in. E.G.
>If I make my *.py scripts executable and place them in /usr/local/bin I
>can execute them from any directory as a normal user just by name, from
>eterm or a console shell, instead of having to put in the full path to
>the file/script.
/usr/local/bin is good, but it can get cluttered as you start installing
more software on the system...
If you want a centralized place to put your scripts in your home directory,
you can, like this:
/home/zmerch/pyscripts
and if you cd to /home/zmerch/pyscripts normally to work on the scripts
anyway, all you have to type in is:
./samplescript.py
and it will execute, if:
1) you remember to put the bangpath line as the first line of the script, like:
#!/usr/bin/python -or-
#!/bin/env /usr/bin/python (I think, I don't use this method myself)
2) make sure you set the script executible:
chmod 755 samplescript.py --if you want *any* userid to run it, or
chmod 744 samplescript.py --if you want only your userid to run it.
=-=-=-=-=-=-=-=-=-=-=
If you wanted to make a directory for your scripts that's world findable,
but not /usr/local/bin for clarity, make one up, like:
/usr/local/pyscripts
and edit your /etc/profile to say something like this:
PATH=${PATH}:/usr/local/pyscripts
export PATH
[[ the previous line is heavily dependant on the flavor of shell you run.
If you're running bash, this *should* work, but it is untested, so YMMV. ;-) ]]
HTH,
Roger "Merch" Merchberger
--
Roger "Merch" Merchberger | A new truth in advertising slogan
sysadmin, Iceberg Computers | for MicroSoft: "We're not the oxy...
zmerch at 30below.com | ...in oxymoron!"
More information about the Tutor
mailing list