Linked Questions

70 questions linked to/from Python subprocess readlines() hangs
6280 votes
66 answers
5.2m views

How do I call an external command within Python as if I had typed it in a shell or command prompt?
98 votes
7 answers
111k views

I'm using Python's subprocess.communicate() to read stdout from a process that runs for about a minute. How can I print out each line of that process's stdout in a streaming fashion, so that I can ...
62 votes
3 answers
77k views

I am using Popen to call a shell script that is continuously writing its stdout and stderr to a log file. Is there any way to simultaneously output the log file continuously (to the screen), or ...
26 votes
8 answers
57k views

I am trying to grab stdout from a subprocess.Popen call and although I am achieving this easily by doing: cmd = subprocess.Popen('ls -l', shell=True, stdout=PIPE) for line in cmd.stdout.readlines(): ...
38 votes
1 answer
87k views

My python script (python 3.4.3) calls a bash script via subprocess: import subprocess as sp res = sp.check_output("bashscript", shell=True) The bashscript contains the following line: ssh -MNf ...
Kevin S.'s user avatar
  • 1,210
30 votes
4 answers
106k views

I'm writing a python script that uses subprocess.Popen to execute two programs (from compiled C code) which each produce stdout. The script gets that output and saves it to a file. Because the output ...
22 votes
3 answers
9k views

Ok so I'm trying to run a C program from a python script. Currently I'm using a test C program: #include <stdio.h> int main() { while (1) { printf("2000\n"); sleep(...
26 votes
3 answers
10k views

I am trying to find a way in Python to run other programs in such a way that: The stdout and stderr of the program being run can be logged separately. The stdout and stderr of the program being run ...
J.J's user avatar
  • 3,617
19 votes
2 answers
36k views

Im trying to handle tcpdump output in python. What I need is to run tcpdump (which captures the packets and gives me information) and read the output and process it. The problem is that tcpdump ...
9 votes
4 answers
12k views

I'm trying to write a python program that is able to interact with other programs. That means sending stdin and receiving stdout data. I cannot use pexpect (although it definitely inspired some of the ...
9 votes
4 answers
16k views

I am trying to assign the output of a command to a variable without the command thinking that it is being piped. The reason for this is that the command in question gives unformatted text as output if ...
13 votes
1 answer
17k views

I'm having problems redirecting stdio of another program using subprocess module. Just reading from stdout results in hanging, and Popen.communicate() works but it closes pipes after reading/writing. ...
Ivan Baldin's user avatar
  • 3,509
11 votes
3 answers
26k views

I am using a python script to run a process using subprocess.Popen and simultaneously store the output in a text file as well as print it on the console. This is my code: result = subprocess.Popen(...
21 votes
3 answers
7k views

I have the following chunk of Python code (running v2.7) that results in MemoryError exceptions being thrown when I work with large (several GB) files: myProcess = Popen(myCmd, shell=True, stdout=...
11 votes
2 answers
8k views

I'm telling jupyter to execute a python script: !python build_database.py When executed from the terminal, the python script prints the progress during execution. However, in the jupyter notebook, I ...
Benni's user avatar
  • 785

15 30 50 per page
1
2 3 4 5