I want to write a background task. so i write a basic script for seeing the working of the shell_exec The script is as follows:
<?php
$op = shell_exec("php -v");
echo $op;
echo "back to the test.php";
?>
Output should be the php version information but it prints the following unexpected output:
back to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.php
it's print my current pages content 59-60 times and sometimes with content-type:text/html
I have tried using another php file output is same
Then I have tried with linux commands like date,ls it works perfectly Please help me to sort out this problem I couldn't make out what is wrong?
I have tried out the absolute paths to php also but no difference and also use other php function like system,exec etc.
Edit Note: I have changed the exec function to shell_exec because I have missplaced this The output which i displayed below is from shell_exec
UPDATE I have not get the solution of the problem but got the cause of the problem there is nothing problem in a script it's because of server. I have write to support center of the server but doesn't get the response So I think this question is closed
I think exec and those kind of functions are 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.