The command below is a shell command that works for me.
php -f /home3/kintest2/www/project/keygen_msql_adjuster.php
What i would like to do is the make this command run from a php file.
Any hints are welcomed
What's wrong with:
include('/home3/kintest2/www/project/keygen_msql_adjuster.php');
or is there a particular reason you want to fire off a whole new PHP interpreter instance?
I'd note that a good reason not to use include is because anything declared therein will pollute your current instance's namespace.
On the flip side, calling shell_exec or similar can be a massive security hole. If your code is running in a restricted environment that may not matter, though.
You can use backticks or system or shell_exec or popen, depending on what you want to do with the process you start.
I think you are looking for shell_exec:
echo shell_exec ( "php -f /home3/kintest2/www/project/keygen_msql_adjuster.php" );
You might also consider using a command-running library that handles errors and things properly: https://github.com/kamermans/command
Then you can run the program like this:
use kamermans\Command\Command;
$cmd = Command::factory('php')
->option('-f', 'keygen_msql_adjuster.php')
->setDirectory('/home3/kintest2/www/project')
->run();
Or, more simply put:
use kamermans\Command\Command;
$cmd = Command::factory('php -f /home3/kintest2/www/project/keygen_msql_adjuster.php');
Unlike PHPs built-in methods, this method will throw a PHP Exception if the command fails, which you can then catch and handle if need be:
use kamermans\Command\Command;
use kamermans\Command\CommandException;
$cmd = Command::factory('php')
->option('-f', 'keygen_msql_adjuster.php')
->setDirectory('/home3/kintest2/www/project');
try {
$cmd->run();
} catch (CommandException $e) {
die("The command failed: ".$e->getMessage()."\n");
}
exec,shell_exec.shell_exec()