subprocess

Python subprocess.Popen - adding GCC flags results in "no input files" error

I'm building a Python script to automate my build process, which invokes GCC using subprocess.Popen. My initial attempt works fine. >>> import subprocess >>> p = Popen(['gcc', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT) >>> p.wait() 0 >>> p.communicate() ('', None) However, once I pass additional options to G...

FFMPEG and Pythons subprocess.

I'm trying to write a gui for FFMPEG. I'm using pythons subprocess to create a ffmpeg process for every conversion I want. This works fine, but I'd also like a way to get the progress of the conversion, whether it failed or not etc. I figured I could do this by accessing the process's stdout like so: Calling subprocess.Popen() # Conver...

Programmatically determine maximum command line length with Python

Does anyone know a portable way for Python to determine a system's maximum command line length? The program I'm working on builds a command and feeds it to subprocess. For systems with smaller command line length maximums, it is possible that the command will be too long. If I can detect that, the command can be broken up to avoid exc...

Drools SubProcess out mapping failed - what am I doing wrong?

I created two "Hello World" processes to give the subProcess nodes a whirl. I'm having trouble getting output from the subProcess back to the main process. I'm hoping someone can enlighten me on what I'm doing wrong as I can't find any documentation or examples that shed light on why mine doesn't work. In my main process, I have the fol...

Get partial stdout and stderr from Popen that runs indefinitely

I'm building a wrapper around a server cmd line script that should run indefinitely. What I need to do is to get the current stout without waiting for the subprocess to finish. I mean, if I run the following, everything works fine: ls = Popen(["ls"], stdout=PIPE) output = ls.stdout.read() But if I do the same with an indefinitelly ru...

Python, subprocess, devenv, why no output?

I build a Visual Studio solution from a Python script. Everything works nicely, except that I am unable to capture the build output. p = subprocess.Popen(['devenv', 'solution.sln', '/build'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = p.communicate() ret = p.returncode Here, both out and err are always empty. This ha...

Need a workaround: Python's select.select() doesn't work with subprocess' stdout?

From within my master python program, I am spawning a child program with this code: child = subprocess.Popen(..., stdout=subprocess.PIPE, stdin=subprocess.PIPE) FWIW, the child is a PHP script which needs to communicate back and forth with the python program. The master python program actually needs to listen for communication from s...

Python Documentation Refers You To Docs for "the C function wait." Where is that?

There's multiple places in the Python documentation where it refers you to the C function "wait." For instance: "The exit status for the command can be interpreted according to the rules for the C function wait," in the commands and subprocess modules. Where can I find this documentation? Apparently my Google-fu is not strong enough, or...

How to interpret status code in Python commands.getstatusoutput()

In a related question, I asked where to find the documentation for the C function "wait." This was an attempt to figure out return codes for the commands.getstatusoutput() module. Stackoverflow came through, but the documentation didn't help. Here's what puzzles me: #!/usr/bin/python import commands goodcommand = 'ls /' badcommand = 'ls...

Is there a cross-platform exec in Boost?

I want to execute a sub-process in C++. I need it to work on Windows and Linux. Is there such a function in Boost? What is the standard way of doing it? ...

os.popen subprocess conversion

Hi Pythoners. This snippet gets me the dotted quad of my BSD network interface. I would like to figure out how to use the subprocess module instead. ifcfg_lines = os.popen("/sbin/ifconfig fxp0").readlines() x = string.split(ifcfg_lines[3])[1] Seems as if I can't use subprocess in exactly the same way. I don't think I want shell=True ...

blocks - send input to python subprocess pipeline

I'm testing subprocesses pipelines with python. I'm aware that I can do what the programs below do in python directly, but that's not the point. I just want to test the pipeline so I know how to use it. My system is Linux Ubuntu 9.04 with default python 2.6. I started with this documentation example. from subprocess import Popen, PIPE...

Encoding of arguments to subprocess.Popen

I have a Python extension to the Nautilus file browser (AFAIK this runs exclusively on GNU/Linux/Unix/etc environments). I decided to split out an expensive computation and run it as a subprocess, pickle the result and send it back over a pipe. My question concerns the arguments to the script. Since the computation requires a path argume...

catching stdout in realtime from subprocess

I have read tons of posts but still can't seem to figure it out. I want to subprocess.Popen() rsync.exe in windows, and print the stdout in python. My code works, but it doesn't catch the progress until a file is done transfered! I want to print the progress for each file in realtime. Using python 3.1 now since I heard it should be be...

Run time of a subprocess.Popen instance

Is there an easy way to find out the current (real or cpu) run time of a subprocess.Popen instance? ...

How do I close the stdout-pipe when killing a process started with python subprocess Popen?

I wonder if it is possible to shut down the communication pipe when killing a subprocess started in a different thread. If I do not call communicate() then kill() will work as expected, terminating the process after one second instead of five. I found a discussion of a similar problem here, but I got no real answers. I assume that I eit...

Problem Using Python's subprocess.communicate() on Windows

I have an application that I am trying to control via Python and the subprocess module. Essentially what I do is start the application using Popen (which opens a command prompt within which the program executes) and then at some point in time later on in the execution I need to send a string (a command) to the STDIN of that program. Th...

Can you only communicate once with a subprocess?

communicate's documentation says: Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. What do you do if you need to send input to a process more than once ? For example, I spawn a process, send it some data, the process does something with that, ...

python popen working directory argument

hi all, I there a way to specify the running directory of command in subprocess.Popen() like Popen('c:\mytool\tool.exe',workingdir='d:\test\local') and my python script locates in c:\programs\python. IS there possible i can run c:\mytool\tool.exe in 'd:\test\local' ? it seems c:\mytool\tool.exe runs in my c:\programs\python as w...

Parsing output of apt-get install for progress bar

I'm working on a simple GUI Python script to do some simple tasks on a system. Some of that work involves apt-get install to install some packages. While this is going on, I want to display a progress bar that should update with the progress of the download, using the little percentage shown in apt-get's interface in the terminal. BUT!...