Jump to content


This topic is now archived and is closed to further replies.


Calling external program on Windows

Recommended Posts

Hi, I have what I belive to be a fairly easy question, but the problem here is escaping me.  I am trying to call an external program using PHP and I want to read data out of that program and also send data to it.  It seems that using proc_open() is the obvious choice here, but I can't seem to read anything from the streams, or even tell if the program is running.  I get a command window opening up, but it just hangs until I kill the window.  I'm trying to automate the processing of a bunch of DNA sequences using a freeware program called rnafold that's available at http://www.tbi.univie.ac.at/~ivo/RNA/  There is a windows binary available, and I was hoping to use this as I don't have a Linux system that I can easily work on.  If anyone is up for a little challenge, and can get php to communicate with the windows rnafold executable I would be greatly appreciative.

My attempt so far has been:

$specs = array(
0 => array("pipe","r"), //stdin
1 => array("pipe", "w"), //stdout
2 => array("pipe", "w") //stderr

$command = "C:\\RNAfold.exe -C";

$handles = array();
$process = proc_open($command,$specs, $handles);

$buffer = fgets($handles[1], 1024); //just trying to read the response from the program


This code looks like it successfully calls the rnafold program, but it just hangs at that point.  I don't see the output of the program echoed back to me, and I can't seem to send any commands to the program via fwrite();

Any suggestions, or am I missing something obvious?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.