popen

Start nano as a subprocess from python, capture input

Hello, I'm trying to start a text editor (nano) from inside Python, have the user enter text, and then capture the text once they writeout (Control-O). I haven't worked with the subprocess module before, nor pipes, so I don't know what to try next. So far I have this code: a = subprocess.Popen('nano', stdout=subprocess.PIPE, shell=True...

Open File With Python

I am writing a tkinter program that is kind of a program that is like a portfolio and opens up other programs also writen in python. So for example i have FILE_1 and FILE_2 and i want to write a program that onced clicked on a certain button opens either FILE_1 or FILE_2. i dont need help with the look like with buttons just how to wir...

popen equivalent in c++

Is their any C popen() equivalent in C++ to ? ...

Can python open a mp3 file

Is it possible to open a mp3 file in python (possible using POPEN) and i dont mean to run it in the program i mean as a separate window in media player or whatever just for it to open it when i call the function and if so how. thanks a lot. ...

How to synchronize the output of Python subprocess

Hi all, I think I'm having issues to synchronize the output of two Popen running concurrently. It seems that the output from these two different command lines are interleaved with one another. I also tried using RLock to prevent this from happening but it didn't work. A sample output would be: cmd1 cmd1 cmd2 cmd2 cmd2 cmd2 cmd1 cmd2 ...

Rescuing "command not found" for IO::popen

When I use IO::popen with a non-existent command, I get an error message printed to the screen: irb> IO.popen "fakefake" #=> #<IO:0x187dec> irb> (irb):1: command not found: fakefake Is there any way I can capture this error, so I can examine from within my script? ...

Executing .jar file from PHP through cmd prompt and capturing output

Hi, I have a jar file of my application which has more than one class. The jar file is called by PHP through the command prompt. I am using the following PHP snippet to call the jar file. <?php $result=popen('java -jar D:\\Development\\Filehandler\\dist\\Filehandler.jar getConfigLang', "r"); while(!feof($result)){ print fread($result,...

LD_PRELOAD affects new child even after unsetenv("LD_PRELOAD")

my code is as follows: preload.c, with the following content: #include <stdio.h> #include <stdlib.h> int __attribute__((constructor)) main_init(void) { printf("Unsetting LD_PRELOAD: %x\n",unsetenv("LD_PRELOAD")); FILE *fp = popen("ls", "r"); pclose(fp); } then in the shell (do the 2nd command with care!!): gcc prel...

Python Popen: are the pipes in blocking mode? how can I put them in non-blocking mode?

Hi, In the subprocess documentation, I haven't found any hint if the pipes created by PIPE are blocking or non-blocking. I.e., if I call p.stdout.read(), will it block in certain circumstances? The documentation warns about that. How can I avoid that? Using p.communicate() is not an option for me because I don't want to block/wait unt...

objective c popen

im looking to execute to execute command line commands from objective c. I know that popen can do this however I am have trouble trying to read and display what the data as an NSString. can anyone tell me how to do this or give me a native objective c function that is equivalent? I probably should have mentioned im trying to write an ap...

Need help with named pipes and popen.

I've got a little C server that needs to accept a connection and fork a child process. I need the stderr of the child process to go to an already existing named pipe, the stdout of the child to go to the stdout of the parent, and the stdin of the child tp come from the same place as the stdin of the parent. My initial attempts involved...

Using popen to write in a pipe only send data when pipe is closed

I'm using popen to open a write pipe and send commands to an application. The problem is that the commands are only sent to the application when I close the pipe. FILE * fp = open(target_app, "w"); fwrite(command, 1, command.size(), fp); getchar(); //wait for a key, because I don't want to terminate the application pclose(fp); // at thi...

How do I eliminate Windows consoles from spawned processes in Python (2.7)?

I'm using python 2.7 on Windows to automate batch RAW conversions using dcraw and PIL. The problem is that I open a windows console whenever I run dcraw (which happens every couple of seconds). If I run the script using as a .py it's less annoying as it only opens the main window, but I would prefer to present only the GUI. I'm involvi...

iPhone popen can't read stdout

I am attempting to execute a shell command from inside an iPhone app I am writing. The app is for jail broken devices. I need to catch the stdout of the command to display it in the app. I know that popen is executing the command because xcode's gdb is showing the output. Also the file pointer returned is not null however when I try to ...

Python subprocess.Popen communicate through a pipeline

I want to be able to use Popen.communicate and have the stdout logged to a file (in addition to being returned from communicate(). This does what I want - but is it really a good idea? cat_task = subprocess.Popen(["cat"], stdout=subprocess.PIPE, stdin=subprocess.PIPE) tee_task = subprocess.Popen(["tee", "-a", "/tmp/logcmd"], stdin=cat...

subprocess.Popen() has inconsistent behavior between Eclipse/PyCharm and terminal execution

The problem I'm having is with Eclipse/PyCharm interpreting the results of subprocess's Popen() differently from a standard terminal. All are using python2.6.1 on OSX. Here's a simple example script: import subprocess args = ["/usr/bin/which", "git"] print "Will execute %s" % " ".join(args) try: p = subprocess.Popen(["/usr/bin/which...

Popen gives "File not found" Error (windows/python)

I'm trying to run console commands via subprocess.Popen, and whenever I run it I get the windows "File not found" error, even when running the echo command. I am also using Popen inside a thread made with the thread module. Is that the problem? ...

first process of python popen pipe can't be killed

I am using this code p1 = Popen(['rtmpdump'] + cmd_args.split(' '), stdout=PIPE) p2 = Popen(player_cmd.split(' '), stdin=p1.stdout, stderr=PIPE) p2.wait() # try to kill rtmpdump # FIXME: why is this not working ? try: p2.stdin.close() p1.stdout.close() p1.kill() except AttributeError: # if we use python 2.5 from sign...

Python and C++ integration. Python prints string as multiple lines.

I'm trying to write a program in python to run a program in C++. It wasn't working right, so I made the most basic version of each I could. The C++ program merely takes in a string from stdin, and then prints it out. The Python code is written as follows: import popen2, string, StringIO fin, fout = popen2.popen2("PyTest") msg = ur"Hel...

Python: How to be notified when the subprocess is ended opened by Popen

Hi, I am using Popen to run a command but I don't know how I can write a callback that gets called once the command is finished. Any idea? Thanks. Bin ...