By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,002 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,002 IT Pros & Developers. It's quick & easy.

calling command line programs?

P: n/a
Hi all,

This is probably a very newbie question, but after searching google and
docs @ python.org I can't find an answer, so maybe someone would be able
to help?

I'd like to call command-line functions from my python script (like you
would in perl using backticks)... Is there a way of doing this? And if
so, how does the environment get treated (I have some variables in my
env that the programs I'd be calling need to see).

Thanks much!
Eugene
Sep 10 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On 2005-09-11, Yevgeniy (Eugene) Medynskiy <ym**@cornell.edu> wrote:
This is probably a very newbie question, but after searching
google and docs @ python.org I can't find an answer, so maybe
someone would be able to help?

I'd like to call command-line functions from my python script
(like you would in perl using backticks)... Is there a way of
doing this? And if so, how does the environment get treated (I
have some variables in my env that the programs I'd be calling
need to see).


Take a look at os.popen, os.spawn, or the popen2, and
subprocess modules.

That last one seems to be gaining popularity.

--
Grant Edwards grante Yow! PEGGY FLEMING is
at stealing BASKET BALLS to
visi.com feed the babies in VERMONT.
Sep 10 '05 #2

P: n/a
Yevgeniy (Eugene) Medynskiy wrote:
Hi all,

This is probably a very newbie question, but after searching google and
docs @ python.org I can't find an answer, so maybe someone would be able
to help?


http://docs.python.org/lib/module-subprocess.html

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Sep 10 '05 #3

P: n/a
Grant Edwards wrote:
On 2005-09-11, Yevgeniy (Eugene) Medynskiy <ym**@cornell.edu> wrote:
This is probably a very newbie question, but after searching
google and docs @ python.org I can't find an answer, so maybe
someone would be able to help?

I'd like to call command-line functions from my python script
(like you would in perl using backticks)... Is there a way of
doing this? And if so, how does the environment get treated (I
have some variables in my env that the programs I'd be calling
need to see).


Take a look at os.popen, os.spawn, or the popen2, and
subprocess modules.

That last one seems to be gaining popularity.


The suggested modules and functions have been deprecated according to the
python 2.4 docs. The doc suggests to use the functions in the 'subprocess'
module.

chriss
Sep 10 '05 #4

P: n/a
On 2005-09-10, chriss <ch****@streiff.org> wrote:
Take a look at os.popen, os.spawn, or the popen2, and
subprocess modules.

That last one seems to be gaining popularity.


The suggested modules and functions have been deprecated according to the
python 2.4 docs. The doc suggests to use the functions in the 'subprocess'
module.


The subprocess module is depricated?

--
Grant Edwards grante Yow! Did you move a lot
at of KOREAN STEAK KNIVES this
visi.com trip, Dingy?
Sep 11 '05 #5

P: n/a
Grant Edwards wrote:
On 2005-09-10, chriss <ch****@streiff.org> wrote:
Take a look at os.popen, os.spawn, or the popen2, and
subprocess modules.

That last one seems to be gaining popularity.


The suggested modules and functions have been deprecated according to the
python 2.4 docs. The doc suggests to use the functions in the
'subprocess' module.


The subprocess module is depricated?

no, the subrocess module intends to replace modules and functions such as:
os.system
os.spawn*
os.popen*
popen2.*
commands.*

have a look at http://python.org/doc/2.4.1/lib/module-subprocess.html
Sep 11 '05 #6

P: n/a
On Sun, 11 Sep 2005 22:32:32 +0200, chriss <ch****@streiff.org>
declaimed the following in comp.lang.python:
Grant Edwards wrote:
On 2005-09-10, chriss <ch****@streiff.org> wrote:
Take a look at os.popen, os.spawn, or the popen2, and
subprocess modules. <snip>
The suggested modules and functions have been deprecated according to the
<snip>
The subprocess module is depricated?
no, the subrocess module intends to replace modules and functions such as:


I think the nit was that the subprocess module HAD been mentioned in
the same sentence (look above the first <snip>) and was not explicitly
excluded from the other modules in the deprecation statement (second
<snip>).

An immediate parse of the sentences, therefore, would conclude that
subprocess IS also deprecated.
-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Sep 11 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.