1

I am running the following php script:

<?php

ini_set('display_errors', 'On');
error_reporting(E_ALL);

date_default_timezone_set('UTC');

echo nl2br("Before\n\n");

$out = shell_exec("ls -lart");
echo "<pre>$out</pre>";

echo nl2br("After\n\n");


?>

I cannot get shell_exec or exec to work at all. The script above produces:

Before
After

but nothing in between.

ali_m
  • 71,714
  • 23
  • 223
  • 298
ManInMoon
  • 6,795
  • 15
  • 70
  • 133

1 Answers1

0

I think shell_exec function is disabled in your php.ini . You can check it by

if(function_exists('shell_exec')) {
    echo "shell_exec is enabled";
} else {
    echo "shell_exec is disabled";
}

Open your php.ini and navigate to section disable_functions

If shell_exec is listed under there , remove it.

Then restart apache / php handler.

Also If Safe Mode is enabled this function will not be available. You need to disable it.

Harikrishnan
  • 9,688
  • 11
  • 84
  • 127