Jump to content

Calling external program on Windows


ct_guy

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:

<?php
$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

echo($buffer);

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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.