How to capture multi-line output for commands issued with PHP exec? -
i trying execute system commands in php , capture output of commands output covers multiple lines. using exec(), seems returns value commands generate output on single line.
for example, if run date @ command line get:
wed may 15 15:07:32 est 2013
as expected, if run command php exec using this...
exec("date", $exec_results);
...then value of $exec_results becomes...
array ( [0] => wed may 15 15:07:32 est 2013 )
however, when run time command line this...
real 0m0.000s user 0m0.000s sys 0m0.000s
...but when php this...
exec("time", $exec_results);
... value of $exec_results empty:
array( )
i don't need run date or time in application these examples of how single line vs. multi-line output on command line seems change gets php.
the documents say:
if output argument present, specified array filled every line of output command.
so why $exec_results array not being filled lines seen when time command run in command line?
notes - have run command line entries apache user rule out privileges.
this should work you
ob_start(); passthru("ls -la"); $dat = ob_get_clean();
Comments
Post a Comment