popen

How do I translate Ruby's IO.popen calls into Python's subprocess.Popen calls?

I've read the documentation and I've tried lots of things in the REPL, and Googled, but I can't for the life of me understand how subprocess.Popen works in Python. Here is some Ruby code I am using: IO.popen("some-process") do |io| while(line = io.gets) # do whatever with line end end How do I translate this into Python using...

Subprocess statement works in python console but not work in Serverdensity plugin?

in the python console the following statement works perfectly fine (i guess using eval that way is not really good, but its just for testing purpose in this case and will be replaced with proper parsing) $ python >>> import subprocess >>> r = subprocess.Popen(['/pathto/plugin1.rb'], stdout=subprocess.PIPE, close_fds=True).communicate()[...

Python's Popen cleanup

I wanted to use a python equivalent to piping some shell commands in perl. Something like the python version of open(PIPE, "command |"). I go to the subprocess module and try this: p = subprocess.Popen("zgrep thingiwant largefile", shell=True, stdout=subprocess.PIPE) This works for reading the output the same way I would in perl, bu...

how to call a program from python without waiting for it to return

is there a way to call a program from python without waiting for it to return? i created a script which copies a program to a directory and runs that program. but when i call the program from python, the python script does not exit until the program i launched exits. i have tried os.system and Popen. is there another way to do this? Add...

How to send value to _popen?

Hi, I have a problem here. I need to send some value to 'text1 and 'text2'. For example, text1 = ...and this code below will refer to those values.. FILE *child = _popen("java -jar c:\\simmetrics.jar text1 text2 > c:\\test.txt", "r"); How can achieve it. I have done many ways, and it keep on giving me pointer errors. ...

Problem with input filter using doxygen 1.6.3 on windows XP

I am trying to use doxygen to generate documentation for some matlab classes I have written. I am using the doxygen-matlab package, which includes a perl script to kludge matlab .m files into c++ style commented files, so that doxygen can read them. In my doxyfile, I have set (according to the instructions) FILTER_PATTERNS = *m=...

Variable popen calls in C

I'm trying to execute MS-DOS DEL commands inside a Win32 C program, and I already know that system and popen can be used for this. However, the problem is that both require string literals (type const char) for the commands, and I need something like the DOS equivalent of this Perl code (more or less, don't know if it actually works): m...

convert Ruby to C languge, Would anyone care to take a look?

I have seen this sample written in Ruby code, how i can simulate it in C language? Open3.popen3(command) do |stdin, stdout, stderr| @stop_stdin = stdin while !stdout.eof do output = stdout.read(1024 * 100) list_pipes.each do |out| out.print output end end end ...

popen fails with "sh: <command>: not found"

I'm developing a server application and I recently encountered this wierd error on a testing server (Debian Squeeze). Every executable I pass to popen fails with a msg: sh: sort: not found // happens to any command This happens regardless whether I point to the full path returned by "type" or keep it short . As mentioned earlier, thi...

python popen command.....wait until the command is finished

Hi, I have a script where I launch with popen a shell command. The problem is that the script don't wait that popen command is finished and go forward. om_points = os.popen(command, "w") ..... How can I tell to my python script to wait until the shell command has finished? Thanks. ...

Python subprocess.Popen hangs in 'for l in p.stdout' until p terminates, why?

I have that code: #!/usr/bin/python -u localport = 9876 import sys, re, os from subprocess import * tun = Popen(["./newtunnel", "22", str(localport)], stdout=PIPE, stderr=STDOUT) print "** Started tunnel, waiting to be ready ..." for l in tun.stdout: sys.stdout.write(l) if re.search("Waiting for connection", l): ...

How to determine subprocess.Popen() failed when shell=True

Windows version of Python 2.6.4: Is there any way to determine if subprocess.Popen() fails when using shell=True? Popen() successfully fails when shell=False >>> import subprocess >>> p = subprocess.Popen( 'Nonsense.application', shell=False ) Traceback (most recent call last): File ">>> pyshell#258", line 1, in <module> p = subp...

Processing: popen() call to start subprocess?

Here's an example of opening and reading data from a TCP socket. Is there a a popen() call or equivalent that can start a child process and read its output? void setup() { c = new Client(this, "127.0.0.1", 12345); // Replace with your server's IP and port } void draw() { if (c.available() > 0) { input = c.readString();...

Java: popen()-like function?

This is in the context of a local Processing program. I would like to run an external program to get some data. Is there a popen() or equivalent function I can use? ...

How to use IO.popen to write-to and read-from a child process?

I am running net share from a ruby script to delete a windows network share. If files on the share are in use, net share will ask the user if they want to go ahead with the deletion, so my script needs to inspect the output from the command, and write out Y if it detects that net share is asking it for input. In order to be able to wri...

Python - Launch a Long Running Process from a Web App

I have a python web application that needs to launch a long running process. The catch is I don't want it to wait around for the process to finish. Just launch and finish. I'm running on windows XP, and the web app is running under IIS (if that matters). So far I tried popen but that didn't seem to work. It waited until the child pr...

Using popen, but text looks weird - Python

Hi folks, I'm using os.popen() in order to run a few commands. This is what "man ls" looks like: Any ideas why the text is displayed as such. I tried both Arial and Consolas fonts. Help would be amazing! Thanks ...

How to take advantage of subprocess within Django? - Django

Hi folks, I'm currently using os.popen() but have been recommended to use subprocess.popen() instead. Any ideas on how I can integrate this? It would be cool and fun to have a Python shell accessible on a Django app. But I reckon that it might be a bit complex to implement. I guess I would have to retrieve the subprocess, as a new re...

Python encoding for pipe.communicate

I'm calling pipe.communicate from Python's subprocess module from Python 2.6. I get the following error from this code: from subprocess import Popen pipe = Popen(cwd) pipe.communicate( data ) For an arbitrary cwd, and where data that contains unicode (specifically 0xE9): Exec. exception: 'ascii' codec can't encode character u'\x...

Access Denied when using popen - Python

Hi folks, I'm using popen in order to send a few commands within a Django app. Problem is that I'm getting [Error 5] Access Denied, apparently I have no access to cmd.exe, which popen seems to use. WindowsError at /test/cmd/ [Error 5] Access is denied: 'C:\WINDOWS\system32\cmd.exe /c dir' I reckon this is because the app sit...