473,769 Members | 8,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling command line programs?

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
6 1549
On 2005-09-11, Yevgeniy (Eugene) Medynskiy <ym**@cornell.e du> 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
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
Grant Edwards wrote:
On 2005-09-11, Yevgeniy (Eugene) Medynskiy <ym**@cornell.e du> 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
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
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
On Sun, 11 Sep 2005 22:32:32 +0200, chriss <ch****@streiff .org>
declaimed the following in comp.lang.pytho n:
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.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.ne tcom.com/> <

Sep 11 '05 #7

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

Similar topics

4
2238
by: RR | last post by:
Hello, I am trying to call a program in python as I would call it in the command line. For example I want to do the following from python: command > file. Then read this file. How do I call "command > file" ? Much help appreciated. -RR
2
4752
by: Shailan | last post by:
Hi Im having trouble with the following code that seems to be behave differently when called from the browser as opposed to the command line. The calling script is a cgi that forks, with the child trying to call another cgi script and pass arguments to it. It works fine from the command line, and calls the required script and passes the arguments correctly. However, when it is run on the browser, it calls the script but does not pass...
7
23864
by: Mark DuPrey | last post by:
I've got a script in an ASP page that is supposed to extract certain files from a zip file, move them, create a new zip with the moved files and then make a self-extracting archive out of the new zip file. I'm doing this using wshShell.Exec, the WinZip command line tool and zip2exe.exe from the pkware suite (because WinZip's command line doesn't support creating self-extracting archives and for historical compatibility reasons). This is...
35
2892
by: Michel Sanner | last post by:
Hello, One of the greatest feature of Python in my opinion is the way the interpreter can be used to integrate a wide variety of software packages by dynamically linking them. This approach has been extremely successful for us so far but now I run into a license nightmare. Some the libraries we wrapped using SWIG are under GPL but the applications we are distributing are not (mainly because
51
4158
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under Command Prompt or Browser or some other application? Ojas.
16
3785
by: Jaco Naude | last post by:
Hi there, This is my first post over here and I hope someone can give me some guidance. I'm trying to embed Python into a Visual C++ 2008 application and I'm getting linker problems. I've compiled a DLL of the Python source code using the pythoncode VC++ project in the PCbuild folder of the source download and this works 100% without any warnings etc. I've done this in Debug and Release mode without any problems.
2
2771
by: John Wright | last post by:
I have a central program I am starting to develop that will track processing deviations. This program is VB 2008 and needs to be called from VB 2005 programs and VB2008 programs (we have some VB 6 programs as well but I these are getting phased out). I need to call this program, pass the logged in user name, and fill in essential data from the calling program into the called program. I don't really want to create a deviation form for all...
8
1990
by: Derek Hart | last post by:
I am unclear about what all the requirements are to call a simple vb.net application, installed in the GAC, from COM (such as writing vba in Word to call the dotnet dll). I believe I have installed the dll in the GAC. It is in there and has a public token. I did not create a key-value pair. I believe it is strong named, as it shows up in the GAC. How do I browse the objects of it? I would like to call it late bound, but the errors I...
0
13361
amitpatel66
by: amitpatel66 | last post by:
There is always a requirement that in Oracle Applications, the Concurrent Program need to be execute programatically based on certain conditions/validations: Concurrent programs can be executed programatically either from UNIX or Oracle PLSQL. In this Section, I will be explaining about calling a Concurrent program from UNIX using the CONCSUB Command. Pre-requisite: 1. Concurrent Program should be registered in oracle Applications...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.