I am trying to execute an external command on my Linux (RedHat 7.2) machine through PHP. Unfortunately, it doesn't seem to be working.
Here is my web page's source code:
That returns a blank page, and /home/myhome/ls_results.txt does not appear.
Trying a different function:
The web page that returns looks like this:
Last Line:
Results:
Return Value: 1
safe_mode is off. Any ideas?
Here is my web page's source code:
Code:
<?php $cmd = "ls /home/myhome > /home/dgable/ls_results.txt";
$results = shell_exec($cmd);
?>
<html>
<body>
<?php echo $results;
?>
</body>
</html>
That returns a blank page, and /home/myhome/ls_results.txt does not appear.
Trying a different function:
Code:
<?php $cmd = "ls /home/myhome > /home/myhome/ls_results.txt";
$last_line = exec($cmd, $results, $ret_val);
?>
<html>
<body>
<?php echo "Last Line: " . $last_line . "<br>";
echo "Results: " . implode("<br>", $results) . "<br>";
echo "Return Value: " . $ret_val;
?>
</body>
</html>
The web page that returns looks like this:
Last Line:
Results:
Return Value: 1
safe_mode is off. Any ideas?