Welcome to the most active Linux Forum on the web.
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 08-01-2007, 04:36 PM   #1
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Rep: Reputation: 32
python - getting command result

Greetings all,

I'm new to python and I need a way to get the results of a command, not the exit status. As an example take "ls" i'm looking for something like

output = someCommand("ls")

os.system is neat, but this gives me the exit status not the result of the command
Old 08-01-2007, 06:22 PM   #2
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu
Posts: 207

Rep: Reputation: 37
output = os.popen('ls').read()



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
Result of a command as gaim away/profile anamericanjoe Linux - Software 0 06-28-2006 11:32 PM
Output the result of a command to a file darkarcon2015 Linux - Newbie 1 09-24-2005 06:29 PM
Strange ip from the result of tracert command mrpc_cambodia Linux - Networking 4 01-25-2005 06:49 AM
BASH Command Result redhatnoob Programming 2 08-19-2004 06:25 PM
cp command problem..... unexpected result hamster Linux - General 2 04-10-2003 04:57 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:01 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
Open Source Consulting | Domain Registration