Reputation: 5068
How do I execute a linux command in PHP and echo the output in original format?
$out = shell_exec('df');
echo $out;
It seems that this simple method will only print the output in a long string format rather than with the correct number of spaces, tabs, line separators. Any assistance is appreciated. Thanks!
Upvotes: 1
Views: 434
Reputation: 78984
For a browser:
echo "<pre>$out</pre>";
Browsers render HTML. Whitespace has no meaning in HTML, only to format the source. pre
tags instruct the browser to render the text as pre-formatted text.
Upvotes: 4