Thread: php and exec
View Single Post
  #10  
Old 10-06-2012, 01:32 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,296
not sure why yet, but following tests may inspire others:
PHP Code:
<?php
echo "<pre>";
out("echo \$PATH");
out("echo $PATH");
out("PATH=/usr/local/bin:/bin:/usr/bin /usr/bin/which ls");
out("/usr/bin/which ls");
out("id");
out("alias");
out("env");
echo 
"</pre>";

function 
out($cmd) {
  
$out = `$cmd`;
  echo 
":: [$cmd]\n\t$out\n";
}
?>
the output(in browser):
Quote:
:: [echo $PATH]
/usr/local/bin:/bin:/usr/bin

:: [echo ]


:: [PATH=/usr/local/bin:/bin:/usr/bin /usr/bin/which ls]
/bin/ls

:: [/usr/bin/which ls]

:: [id]
uid=555(shooting) gid=555(shooting) groups=555(shooting)

:: [alias]

:: [env]
PHPRC=/home/shooting/
PWD=/home/shooting/public_html/Darladog
SHLVL=1
_=/bin/env
Reply With Quote