Re: running C/Fortran progz via command line ?
| From: | Mike Eheler | Date: | Mon, 15 Oct 2001 19:28:13 +0000 |
| Subject: | Re: running C/Fortran progz via command line ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71133@lists.php.net to get a copy of this message | ||
use the "passthru" function to execute a program, then use output buffering to control it's output:
http://www.php.net/manual/en/ref.outcontrol.php
http://zend.com/zend/art/buffering.php
http://phpbuilder.com/columns/argerich20010125.php3
http://www.phpdev.com/view.phph/4.html
A small example:
<?php
ob_start();
passthru('ls -lA /usr');
$text = ob_get_contents();
ob_end_clean();
echo "<pre>" . htmlspecialchars($text) . "</pre>";
?>
Mike
Lee wrote:
Hi, I wonder if anyone could perhaps answer a question for me regarding PHP and it's ability to inter(face/act) with external applications - running on the same (linux) machine. I am developing a web application and one of it's functions requires it to be able to execute programs (mainly written in c, but also Fortran) via command lines including all the required arguments; e.g. ./do-something -i1 file1.txt - i2 file2.txt -o results.txt In some cases the program output would have to be obtained (and returned to PHP for processing), and in others it would not - some of the calculations take a few hours - in which case the results would be mailed directly to the user when complete. I anticipate the flow of things will be as follows: 1-User will submit some data / upload files via web forms. 2-PHP will then use this data and then generate a command to execute an external program running on the same machine. 3-The user can then be notified if the program executed correctly, and if applicable, return any data. Can PHP be of any use here? Is the above possible? Is anyone doing something similar at the present time? If anyone could provide me with any information, I would greatly appreciate it. - Best regards, Lee Reilly