Linked Questions
14
votes
1answer
54k views
in python, get the output of system command as a string [duplicate]
In python I can run some system command using os or subprocess. The problem is that I can't get the output as a string. For example:
>>> tmp = os.system("ls")
file1 file2
>>> tmp
0
...
8
votes
4answers
29k views
How can I get terminal output in python? [duplicate]
I can execute a terminal command using os.system() but I want to capture the output of this command. How can I do this?
2
votes
3answers
4k views
Python command execution output [duplicate]
Possible Duplicate:
Running shell command from python and capturing the output
I want to capture the output of a command into a variable, so later that variable can be used again. I need to ...
1
vote
2answers
6k views
Simple python command to capture shell execution output? [duplicate]
Possible Duplicate:
Running shell command from python and capturing the output
When I want to capture shell execution output, I do this.
declare TAGNAME=`git describe --tags`
Simple. I looked ...
0
votes
2answers
638 views
Most pythonic way to get output from a shell command [duplicate]
I'm writing my first python program and I want to run a shell command and get the output. I want to do it in the cleanest possible / most pythonic way. This is what I've got atm.
Note: I also want to ...
0
votes
1answer
636 views
I need to run a shell command from python and store the output in a string or file [duplicate]
I will use ls as an example:
I tried:
str = call("ls")
str stored 0.
I tried:
str = call("ls>>txt.txt")
but had no luck (an error occured & txt.txt wasn't created).
How do I perform ...
1
vote
2answers
205 views
python os.system command line return value back to python [duplicate]
I am calling a second python script that is written for the command line from within my script using
os.system('insert command line arguments here')
this works fine and runs the second script in ...
0
votes
1answer
113 views
How to redirect shell script output ran from a python script [duplicate]
I am executing few shell scripts from a python script. A particular shell script(last line of the code) call is used to run a Hive query to get some table information and I would like to redirect this ...
0
votes
2answers
198 views
How to store output of hcitool lescan? [duplicate]
I was trying to scan ble devices using hcitool lescan in a python code. The hcitool lescan works well on the command line but fails to return any output using subprocess.Popen.The code works fine when ...
-2
votes
1answer
83 views
python run binary application in memory and return output [duplicate]
I want protect my commercial application with hwid protection, I have this demidecode : http://gnuwin32.sourceforge.net/packages/dmidecode.htm return UUID of computer where run, the problem is need ...
0
votes
1answer
74 views
How can I get the full response after pinging a server and assign it to a variable in Python? [duplicate]
I want to be able to ping a server, and instead of just being returned with 0 or 1, I want to be able to see what you would see if you ran it in terminal your self, for example be able to see how many ...
0
votes
0answers
24 views
Using bash command with python [duplicate]
I need to execute this bash command with python:
variable=$(openssl passwd -crypt -salt "$salt" "$i$j$k$l")
I'm trying this but i'm a bit lost:
variable = os.popen("openssl","passwd","-crypt","-...
149
votes
4answers
84k views
How to hide output of subprocess in Python 2.7
I'm using eSpeak on Ubuntu and have a Python 2.7 script that prints and speaks a message:
import subprocess
text = 'Hello World.'
print text
subprocess.call(['espeak', text])
eSpeak produces the ...
41
votes
3answers
67k views
Python: How to get stdout after running os.system?
I want to get the stdout in a variable after running the os.system call.
Lets take this line as an example:
batcmd="dir"
result = os.system(batcmd)
result will contain the error code (stderr 0 ...
7
votes
3answers
11k views
What's a good equivalent to python's subprocess.check_call that returns the contents of stdout?
I'd like a good method that matches the interface of subprocess.check_call -- ie, it throws CalledProcessError when it fails, is synchronous, &c -- but instead of returning the return code of the ...