I have this tool which has an interactive shell (like mysql client) I need to feed it a couple commands and then It will produce output (many lines of text) How would I capture its output?
@NogDogFeb 03.2012 — #Usually you can redirect command line output to a file with the ">" operator, e.g.: <i> </i>php my_script.php arg1 arg2 > results.txt
@jeanlucaauthorFeb 03.2012 — #No thats not what I mean.I think you can compare what I need to do with using mysql client. To get data out of this tool you need to open it, feed it a SELECT statement and capture the output.
I noticed that proc_open can do bi-directional stuff. Here is my test script I made using the manual from proc_open
[CODE]<?php $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to );