Faraz H
Faraz H

Reputation: 161

"ps -ef" returns different result when run within php script versus command line

In my test.php script I have this:

$out = exec ( 'ps -ef' );
echo $out;

Which outputs just this when I run "php test.php":

root 16682 2 0 Jan30 ? 00:00:00 [NFSv4 callback]

However, when I run "ps -ef" from the command line I get the usual long list of processes for all users..

Any ideas why the php script produces such different results?

Upvotes: 0

Views: 126

Answers (1)

SydOwl
SydOwl

Reputation: 51

Please try

shell_exec ( 'ps -ef' );

This will return the entire output, whereas exec returns the last line of output:

http://php.net/manual/en/function.exec.php

Upvotes: 1

Related Questions