Re: [Tutor] Running a script from another folder

2008-11-12 Thread Shawn Milochik
On Wed, Nov 12, 2008 at 12:58 PM, greg whittier <[EMAIL PROTECTED]> wrote:
>> it looks like you're on linux - so at the beginning of your script put
>> #!/usr/bin/env python (I believe) and then chmod +x myscript.py
>>
>> then you can call it from the command line.
>>
>
> You'll also need to make sure ~myID/bin is in your PATH.
> _

This is the answer, assuming you have the shebang line and executable
flags mentioned above.

Method (assuming you are using bash):

Add this to your .bashrc file in your home directory:

export PATH=$PATH:${HOME}/bin

I used ${HOME} instead of ~ to make this more portable. However, if
your system doesn't work that way, use the ~ or the full path.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running a script from another folder

2008-11-12 Thread greg whittier
> it looks like you're on linux - so at the beginning of your script put
> #!/usr/bin/env python (I believe) and then chmod +x myscript.py
>
> then you can call it from the command line.
>

You'll also need to make sure ~myID/bin is in your PATH.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running a script from another folder

2008-11-12 Thread W W
On Wed, Nov 12, 2008 at 10:27 AM, <[EMAIL PROTECTED]> wrote:

> Suppose I have a python script in /usr1/myID/bin and I want to run it from
> another folder. If I enter
>
> python ~myID/bin/myscript
>
> that works. Is there a way to get by with
>
> python myscript
>
> or even
>
> myscript.py
>
> I've tried specifying the PYTHONPATH
> environmental variable but it seems to be used only for importing modules


it looks like you're on linux - so at the beginning of your script put
#!/usr/bin/env python (I believe) and then chmod +x myscript.py

then you can call it from the command line.

Alternatively you could create a shell script that would execute it with
python.

HTH,
Wayne
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor