473,508 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Launching Python programs from Linux shell script

Does anyone know how to start Python program(s) from a Linux shell
script? Is it just

$python myscript.py

??

Thanks,

Sep 9 '05 #1
6 2625
Yes, provided your python interpreter is installed, and in your path
("$ whereis python" should give you something like /usr/bin/python or
/usr/local/bin/python)

Sep 9 '05 #2
Yes, provided your python interpreter is installed, and in your path
("$ whereis python" should give you something like /usr/bin/python or
/usr/local/bin/python)

Sep 9 '05 #3
Yes...
-------------------------------------------------
Or...
Add this line in de source:
#!/usr/bin/env python
then
chmod +x myscript.py
../myscript.py
On 9 Sep 2005 08:31:27 -0700, Ernesto <er*******@gmail.com> wrote:
Does anyone know how to start Python program(s) from a Linux shell
script? Is it just

$python myscript.py

??

Thanks,

--
http://mail.python.org/mailman/listinfo/python-list

Sep 9 '05 #4
Thanks! How do you add Python in Linux to the path? Similar to
setting environment variables in Windows. I want to be able to type
"python" when I'm in any directory to launch the interpreter. Thanks!

Sep 12 '05 #5
Ernesto wrote:
Thanks! How do you add Python in Linux to the path? Similar to
setting environment variables in Windows. I want to be able to type
"python" when I'm in any directory to launch the interpreter. Thanks!

You will (or should) have a shell intialisation file variously called
..profile, .bashrc or several other possible names. Consult your shell
documentation (or ask another user who knows) to find out which.

You will need to add a line which typically reads something like

export PATH=$PATH:/path/to/directory/containing/python

making the obvious substitution of the correct path. Interestingly I
couldn't quickly formulate a Google search specifically containing
Python, but a search for

unix add to path

gives the quite helpful

http://www.ee.surrey.ac.uk/Teaching/Unix/unix8.html

as its first result.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Sep 12 '05 #6
Ernesto wrote:
Thanks! How do you add Python in Linux to the path?


This works out of the box in most modern Linux distributions.

If you're open to suggestions, I'd suggest that you have a
look at Ubuntu. It's a user friendly Linux distribution with
rather close ties to the Python community.

Anyway, if Python is installed in a non-standard location on
your machine, you might need to set up two things:

PATH to the directory containing the python binary.
PYTHONPATH to the directories containing Python modules and
packages.

How to do this has nothing to do with Python, it just depends
on what shell(s) you use in Linux, and this is frankly not the
forum for that.

See e.g. http://docs.python.org/tut/node4.html and
http://www.python.org/doc/tut/node8.html for more about PATH
and PYTHONPATH--actually, it might be a good idea to read the
whole tutorial if you're a beginner.
Sep 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3825
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
2
14342
by: Jorgen Grahn | last post by:
I couldn't think of a good solution, and it's hard to Google for... I write python command-line programs under Win2k, and I use the bash shell from Cygwin. I cannot use Cygwin's python package...
10
3660
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
11
4980
by: ronan_boisard | last post by:
hi all, I'm trying to call ksh script from python. I have a file (toto.env) with a scirpt looking like: -- begin --- #!/bin/ksh # export TOTO_ENV=/home/toto -- end ---
7
2228
by: Frank Potter | last post by:
I learned some python in windows. And now I've turned to linux. I read a book and it teaches how to write shell script with bash, but I don't feel like the grammar of bash. Since I know about...
8
2266
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
I would like to find out how I can launch an independent Python program from existing one in a cross-platform way. The result I am after is that a new terminal window should open (for io...
3
3845
by: Gros Bedo | last post by:
Hello :-) I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely....
3
3931
by: mmm | last post by:
I am looking for advice on Python Editors and IDEs I have read other posts and threads on the subject and my two questions at this time are mainly about the IDLE-like F5-run facilities. While I...
5
1763
by: Stef Mientki | last post by:
hello, I'm not familiar with Linux / Ubuntu, still trying to get my application working under these operating systems. I've a script "file_support.py", now when I'm in Ubuntu, open a command...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.