Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Alan Gauld


"michael scott"  wrote 

say, how do I install a program to my computer, so that 
I can use it by its self without running it with python. 


Just to be clear, Python programs are interpreted by 
the Python interpreter. So while you can set things up 
such that you don't need to explicitly cakll Pyhon, 
it will always be there in the background. And if 
you try to run your script on a machine that 
doesn't have Python installed it will fail.


You probably knew that already but I just want to 
set your expectations...



--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread davidheiserca

I think I understand.

One thing you can do is create a "myprogram.bat" file with an entry something 
like:

python c:/myprogrampath/myprogram.py

Put the "myprogram.bat" file in the root directory or any directory in the 
PATH. Then it will behave like an executable.

In Linux, it would be "myprogram.sh" with the executable bit set.



  - Original Message - 
  From: michael scott 
  To: tutor@python.org 
  Sent: Friday, May 20, 2011 11:10 AM
  Subject: Re: [Tutor] Making a script part of the terminal


  Thank you for the reply, but thats not exactly what I mean. Perhaps I should 
say, how do I install a program to my computer, so that I can use it by its 
self without running it with python. No matter what directory I'm in I can type 
mozilla in and it runs, no matter what directory I'm in if I type sudo 
natutilus it will run, no matter what directory I'm in if I type gedit it will 
run. 

  So I'm trying to achieve this with the script I wrote. I don't know the 
terminology to ask the question correctly, so forgive me.


  
  What is it about you... that intrigues me so?





--
  From: James Reynolds 
  To: michael scott 
  Cc: tutor@python.org
  Sent: Fri, May 20, 2011 1:57:57 PM
  Subject: Re: [Tutor] Making a script part of the terminal

  We just had a similar question yesterday.


  Just make sure Python is on your PATH. CD to the directory where your file is 
located and then you can just type "python myfile.py" where myfile is the name 
of your file.


  On Fri, May 20, 2011 at 1:43 PM, michael scott  wrote:

Okay, my title might be undescriptive, let me try to explain it better. I 
want to take a script I've written and make it usable by typing its name in the 
terminal. Perfect example is the python interpreter. You just type in the word 
python to the terminal and then the interpreter runs. I know other programs can 
do this as well (like mozilla or nautilus or rhythmbox).  So how do I make my 
scripts executable from the terminal?



What is it about you... that intrigues me so?



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor






--


  ___
  Tutor maillist  -  Tutor@python.org
  To unsubscribe or change subscription options:
  http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Joel Goldstick
On Fri, May 20, 2011 at 2:10 PM, michael scott wrote:

> Thank you for the reply, but thats not exactly what I mean. Perhaps I
> should say, how do I install a program to my computer, so that I can use it
> by its self without running it with python. No matter what directory I'm in
> I can type mozilla in and it runs, no matter what directory I'm in if I type
> sudo natutilus it will run, no matter what directory I'm in if I type gedit
> it will run.
>
> So I'm trying to achieve this with the script I wrote. I don't know the
> terminology to ask the question correctly, so forgive me.
>
>
> 
> What is it about you... that intrigues me so?
>
>
> --
> *From:* James Reynolds 
> *To:* michael scott 
> *Cc:* tutor@python.org
> *Sent:* Fri, May 20, 2011 1:57:57 PM
> *Subject:* Re: [Tutor] Making a script part of the terminal
>
> We just had a similar question yesterday.
>
> Just make sure Python is on your PATH. CD to the directory where your file
> is located and then you can just type "python myfile.py" where myfile is
> the name of your file.
>
> On Fri, May 20, 2011 at 1:43 PM, michael scott wrote:
>
>> Okay, my title might be undescriptive, let me try to explain it better. I
>> want to take a script I've written and make it usable by typing its name in
>> the terminal. Perfect example is the python interpreter. You just type in
>> the word python to the terminal and then the interpreter runs. I know other
>> programs can do this as well (like mozilla or nautilus or rhythmbox).  So
>> how do I make my scripts executable from the terminal?
>>
>> 
>> What is it about you... that intrigues me so?
>>
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>

You need to do the #!/usr/bin/env python or #!/usr/bin/python  thing in your
file
Then change it to being executable as described above
Lastly, you need to put your program in a directly where the $PATH
environment variable knows to look for it
-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Andre' Walker-Loud
Hi Michael,

You have to do three (four) things.

1 - make a directory where you want your executables to live (after you have 
created them)
on my machine, I copy everything to /usr/local/walkloud/bin/  which requires 
sudo, but you can put them anywhere in your $PATH


2 - in your .tcshrc or .cshrc or equivalent file (to figure it out, type echo 
$SHELL to figure out your shell if you have no idea what I am talking about), 
you must append your path.  eg. with tcshrc (in the .tcshrc file) - the .tcshrc 
file is located in your $HOME dir.

setenv PATH /usr/local/walkloud/bin:$PATH

3 - if you haven't, in the directory where your script lives
chmod +x your_script

4 - cp your script to this directory in 1-

launch a new terminal and it should work.


Andre



On May 20, 2011, at 11:10 AM, michael scott wrote:

> Thank you for the reply, but thats not exactly what I mean. Perhaps I should 
> say, how do I install a program to my computer, so that I can use it by its 
> self without running it with python. No matter what directory I'm in I can 
> type mozilla in and it runs, no matter what directory I'm in if I type sudo 
> natutilus it will run, no matter what directory I'm in if I type gedit it 
> will run. 
> 
> So I'm trying to achieve this with the script I wrote. I don't know the 
> terminology to ask the question correctly, so forgive me.
>  
> 
> What is it about you... that intrigues me so?
> 
> 
> From: James Reynolds 
> To: michael scott 
> Cc: tutor@python.org
> Sent: Fri, May 20, 2011 1:57:57 PM
> Subject: Re: [Tutor] Making a script part of the terminal
> 
> We just had a similar question yesterday.
> 
> Just make sure Python is on your PATH. CD to the directory where your file is 
> located and then you can just type "pythonmyfile.py" where myfile is the name 
> of your file.
> 
> On Fri, May 20, 2011 at 1:43 PM, michael scott  wrote:
> Okay, my title might be undescriptive, let me try to explain it better. I 
> want to take a script I've written and make it usable by typing its name in 
> the terminal. Perfect example is the python interpreter. You just type in the 
> word python to the terminal and then the interpreter runs. I know other 
> programs can do this as well (like mozilla or nautilus or rhythmbox).  So how 
> do I make my scripts executable from the terminal?
>  
> 
> What is it about you... that intrigues me so?
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread ian douglas
To expand further, some distributions of Linux set a 'bin' path under 
your home folder as part of your native PATH, even if it doesn't exist.


So if your Linux username is, say, "mscott", see if "echo $PATH" already 
includes something like "/home/mscott/bin" in the path already. If so, 
simply create a bin folder:


mkdir ~/bin

and then place your Python scripts within that folder, and follow 
Edgar's other advice about adding #!/usr/local/bin/python and using 
"chmod +x filename.py" etc.


If you're on a non-Linux platform, I'm sure others can provide further help.

-id



On 05/20/2011 11:03 AM, Edgar Almonte wrote:

hey ! i can answer that !

birst in the fist line of you script put something like this

#!/usr/local/bin/python

change the path for where you have python ( try using 'whereis python' )

sencond make the file executable add the +x attribute ( using chmod )

third  put the script in some place and and that path to the PATH
enviroment variable.

good luck


On Fri, May 20, 2011 at 1:43 PM, michael scott  wrote:

Okay, my title might be undescriptive, let me try to explain it better. I
want to take a script I've written and make it usable by typing its name in
the terminal. Perfect example is the python interpreter. You just type in
the word python to the terminal and then the interpreter runs. I know other
programs can do this as well (like mozilla or nautilus or rhythmbox).  So
how do I make my scripts executable from the terminal?


What is it about you... that intrigues me so?

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread michael scott
Thank you gentlemen so much, I believe I have all that I need to do what I wish.

 
What is it about you... that intrigues me so?___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread michael scott
Thank you for the reply, but thats not exactly what I mean. Perhaps I should 
say, how do I install a program to my computer, so that I can use it by its 
self 
without running it with python. No matter what directory I'm in I can type 
mozilla in and it runs, no matter what directory I'm in if I type sudo 
natutilus 
it will run, no matter what directory I'm in if I type gedit it will run. 


So I'm trying to achieve this with the script I wrote. I don't know the 
terminology to ask the question correctly, so forgive me.

 
What is it about you... that intrigues me so?





From: James Reynolds 
To: michael scott 
Cc: tutor@python.org
Sent: Fri, May 20, 2011 1:57:57 PM
Subject: Re: [Tutor] Making a script part of the terminal

We just had a similar question yesterday.

Just make sure Python is on your PATH. CD to the directory where your file is 
located and then you can just type "python myfile.py" where myfile is the name 
of your file.


On Fri, May 20, 2011 at 1:43 PM, michael scott  wrote:

Okay, my title might be undescriptive, let me try to explain it better. I want 
to take a script I've written and make it usable by typing its name in the 
terminal. Perfect example is the python interpreter. You just type in the word 
python to the terminal and then the interpreter runs. I know other programs can 
do this as well (like mozilla or nautilus or rhythmbox).  So how do I make my 
scripts executable from the terminal?
>
> 
>What is it about you... that intrigues me so?
>
>
>___
>Tutor maillist  -  Tutor@python.org
>To unsubscribe or change subscription options:
>http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Noah Hall
On Fri, May 20, 2011 at 6:43 PM, michael scott  wrote:
> Okay, my title might be undescriptive, let me try to explain it better. I
> want to take a script I've written and make it usable by typing its name in
> the terminal. Perfect example is the python interpreter. You just type in
> the word python to the terminal and then the interpreter runs. I know other
> programs can do this as well (like mozilla or nautilus or rhythmbox).  So
> how do I make my scripts executable from the terminal?


Since you've mentioned Linux applications, I'm going to guess you mean
on Linux only. This is easy. In Unix scripts, we use something called
a shebang. A shebang is the very first line which basically tells the
terminal what program to use to run the script. For Python, it should
be "#! /usr/bin/python" (or where ever your python interpreter is, you
can find this out by using "which python")

Hope this helps.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread r...@schoenian-online.de
Hello Michael,
 
first you have to give your script an executable bit. Just type chmod +x
your_script.py
Furhtermore, your script has to be in a directory that is also part of your
search path. Type in echo $PATH to see how your path is set. You can either link
or copy your script to an approprate location.
 
Regards,
Ralf 
 



michael scott  hat am 20. Mai 2011 um 19:43 geschrieben:


> 
> Okay, my title might be undescriptive, let me try to explain it better. I want
> to take a script I've written and make it usable by typing its name in the
> terminal. Perfect example is the python interpreter. You just type in the word
> python to the terminal and then the interpreter runs. I know other programs
> can do this as well (like mozilla or nautilus or rhythmbox).  So how do I make
> my scripts executable from the terminal?
> 
>  
> What is it about you... that intrigues me so?
>___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Edgar Almonte
hey ! i can answer that !

birst in the fist line of you script put something like this

#!/usr/local/bin/python

change the path for where you have python ( try using 'whereis python' )

sencond make the file executable add the +x attribute ( using chmod )

third  put the script in some place and and that path to the PATH
enviroment variable.

good luck


On Fri, May 20, 2011 at 1:43 PM, michael scott  wrote:
> Okay, my title might be undescriptive, let me try to explain it better. I
> want to take a script I've written and make it usable by typing its name in
> the terminal. Perfect example is the python interpreter. You just type in
> the word python to the terminal and then the interpreter runs. I know other
> programs can do this as well (like mozilla or nautilus or rhythmbox).  So
> how do I make my scripts executable from the terminal?
>
> 
> What is it about you... that intrigues me so?
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Timo

On 20-05-11 19:43, michael scott wrote:
Okay, my title might be undescriptive, let me try to explain it 
better. I want to take a script I've written and make it usable by 
typing its name in the terminal. Perfect example is the python 
interpreter. You just type in the word python to the terminal and then 
the interpreter runs. I know other programs can do this as well (like 
mozilla or nautilus or rhythmbox).  So how do I make my scripts 
executable from the terminal?
I can only speak for Linux, but your script should be in a directory 
that is in the PATH variable of your environment. The reason why you can 
just enter a program name in the terminal, is because these should be in 
/usr/bin or /usr/local/bin and these are in PATH.


Type this in the terminal to see which ones:
echo $PATH

You can either put your script in one of those directories or add on to 
PATH.


Cheers,
Timo



What is it about you... that intrigues me so?


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread James Reynolds
We just had a similar question yesterday.

Just make sure Python is on your PATH. CD to the directory where your file
is located and then you can just type "python myfile.py" where myfile is the
name of your file.

On Fri, May 20, 2011 at 1:43 PM, michael scott wrote:

> Okay, my title might be undescriptive, let me try to explain it better. I
> want to take a script I've written and make it usable by typing its name in
> the terminal. Perfect example is the python interpreter. You just type in
> the word python to the terminal and then the interpreter runs. I know other
> programs can do this as well (like mozilla or nautilus or rhythmbox).  So
> how do I make my scripts executable from the terminal?
>
> 
> What is it about you... that intrigues me so?
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Making a script part of the terminal

2011-05-20 Thread michael scott
Okay, my title might be undescriptive, let me try to explain it better. I want 
to take a script I've written and make it usable by typing its name in the 
terminal. Perfect example is the python interpreter. You just type in the word 
python to the terminal and then the interpreter runs. I know other programs can 
do this as well (like mozilla or nautilus or rhythmbox).  So how do I make my 
scripts executable from the terminal?

 
What is it about you... that intrigues me so?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor