[Pythonmac-SIG] Running Python scripts without full paths
Paul Berkowitz
berkowit@silcom.com
Sat, 30 Nov 2002 12:43:47 -0800
On 11/30/02 12:22 PM, "Nicholas Riley" <njriley@uiuc.edu> wrote:
> On Sat, Nov 30, 2002 at 12:11:32PM -0800, Paul Berkowitz wrote:
>> On 11/30/02 11:45 AM, "Nicholas Riley" <njriley@uiuc.edu> wrote:
>>> Yes, that's one way to do it. If you just want stuff launched from
>>> tcsh to be affected, then use ~/.tcshrc instead.
>>
>> It doesn't work. I would have preferred to have it work for all shells, so I
>> added this to my ~/.MacOSX/environment.plist file:
>>
>> <key>PATH</key>
>> <string>/Users/berkowit/Library/Scripts/Python:</string>
>
> You seem to be including the trailing colon because you think it means
> something??
I thought it was an error in Russell's webpage, but it worked for
PYTHONPATH, so I left it in for "good luck". I removed it from both strings
now, makes no difference to either, but it's cleaner now without it.
>You need to at least include the default PATH
> (/usr/bin:/bin:[home dir]) in the PATH you set in
> ~/.MacOSX/environment.plist, otherwise bad things can happen.
> WindowServer could be throwing out your PATH in an effort to sanity
> check, in fact.
Thank you. I was a little hasty there, but I had saved a text copy of my
full PATH in TextEdit .txt file, just in case. Since it was overwritten, I
was more careful this time. thank you. This time I just added
:/Users/berkowit/Library/Scripts/Python to my existing PATH and put it all
in.
>
> I just added /blah/bin to my PATH in ~/.MacOSX/environment.plist,
> logged out, logged back in, and there it was. When I put only
> /blah/bin in there, my shell started complaining that it couldn't find
> anything (not surprisingly). So be careful.
>
>> which does work. But the PATH key doesn't. I logged out for OS X and back
>> in again. here's what I see:
>>
>> [250-166:~] berkowit% printenv PATH
>> ~/bin/powerpc-apple-darwin:/Users/berkowit/bin:/usr/local/bin:/usr/bin:/bin:
>> /usr/local/sbin:/usr/sbin:/sbin
>
> Something else might be overwriting your path. Remember that you're
> using tcsh whose parent is login whose parent is Terminal whose parent
> is the WindowServer. Check the initial environment of Terminal using
> 'ps -eww'. If that contains your PATH as you've set it, then follow
> the chain of initial environments until you find the one that doesn't
> contain your set PATH.
After logging out and in again, it _is_ now included in 'ps-eww' but not in
'printenv PATH'. What's the nest step(s) to check?
[250-166:~] berkowit% ps -eww
PID TT STAT TIME COMMAND
721 std S 0:00.20 -tcsh HOME=/Users/berkowit SHELL=/bin/tcsh
USER=berkowit
PATH=~/bin/powerpc-apple-darwin:/Users/berkowit/bin:/usr/local/bin:/usr/bin:
/bin:/usr/local/sbin:/usr/sbin:/sbin:/Users/berkowit/Library/Scripts/Python
PYTHONPATH=/Users/berkowit/Library/Scripts/Python DISPLAY=:0.0
__CF_USER_TEXT_ENCODING=0x1F5:0:0 TERM=vt100 TERMCAP=M-??M-W`
TERM_PROGRAM=Apple_Terminal TERM_PROGRAM_VERSION=81 LOGNAME=berkowit
(tcsh)
[250-166:~] berkowit% printenv PATH
~/bin/powerpc-apple-darwin:/Users/berkowit/bin:/usr/local/bin:/usr/bin:/bin:
/usr/local/sbin:/usr/sbin:/sbin
>
>> What am I doing wrong/ I can try it Kevin's way just for tcsh, but I also
>> want to 'do shell script' from AppleScript, which uses bash in OS 10.2.
>> Anyway, why doesn't it work? I added the PATH key and string below DISPLAY
>> and PYTHONPATH. Since it's an (XML) Dictionary, order shouldn't matter,
>> should it?
>
> No. It's better to use Property List Editor than editing the file
> directly, that way you don't have the potential of XML syntax errors
> causing problems. If in doubt, use the 'pl' program (see my previous
> email) to print out the contents of the property list in old-style
> plist format, which happens to be much more compact and human-readable
> than the XML format.
OK, I did it that way this time. Thank you. pretty neat, once I figured out
to click "New Sibling". (!) - not entirely obvious.
Where should I check for what's overwriting the .plist?
--
Paul Berkowitz