Solved

Capture multiple lines of output?

Posted on 2012-03-12
2
223 Views
Last Modified: 2012-03-19
A program executing in windows, produces multiple lines of ouput.

This program just outputs the last line:

<?php
     $str= "prog.exe";
     $output=exec($str);
?>

How can I get all of the lines of output in my variable?
0
Comment
Question by:pillmill
2 Comments
 
LVL 7

Accepted Solution

by:
ziceva earned 500 total points
ID: 37711109
Try this:

<?php
     $str= "prog.exe";
     $output=exec($str,$all);
     print_r($all);
?>

More info here:
http://www.php.net/manual/en/function.exec.php
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 37712093
Not sure, because I have never used exec() but something like this might be worth trying.
<?php 
error_reporting(E_ALL);
ob_start();
exec('prog.exe');
$out = ob_get_clean();
var_dump($out);

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question