Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-21-2009, 04:45 PM   #1
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Run external program from python script

I want to be able to run a program in a python script, and capture it's output in a variable. I figured out that I can execute it with os.system(), but how do I capture it's output and store it in a variable?
Old 12-21-2009, 07:26 PM   #2
Senior Member
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
use the subprocess module.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run an external script, without holding up the currently executing script onesikgypo Programming 2 03-07-2009 10:26 PM
run a bash script using python. deathalele Programming 3 09-13-2008 09:07 PM
python: how do you capture stdout stream from external program? BrianK Programming 8 01-24-2008 09:32 PM
i want to run python program on new built lfs shankara Linux From Scratch 1 02-03-2006 03:42 PM
how to Run python script on .bash_profile warnetgm Linux - Newbie 32 09-08-2005 06:56 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:40 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration