Solved

Capture multiple lines of output?

Posted on 2012-03-12
2
220 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 108

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now