Possible Duplicate:
Calling Perl script from PHP and passing in variables, while also using variablized perl script name
I want to execute a perl script through PHP. I use exec()
to execute the perl script. It works in my machine but does not work on the server. The Server is based on CentOS Linux.
I gave full permission (777) to both the PHP and the perl script file. When I try to execute, I get the following error in error_log
sh: /perl: No such file or directory
I tried to execute using the following ways
exec("perl -w Script.pl $username $password",$output);
exec("/usr/bin/perl -w Script.pl $username $password",$output);
exec("/usr/bin/perl Script.pl $username $password",$output);
I also tried by using the system
function
$output = system("perl Script.pl $username $password");
Nothing happening when I try this.
I also tried to execute perl by using the passthru()
function
passthru("/usr/bin/perl -w Script.pl $username $password",$output);
When I execute this line, $output
prints 127 and nothing happens in the script.
I checked whether file is executable or not with the is_executable()
function. It shows that the file is not executable.
Code as below
$file = 'Script.pl';
if (is_executable($file))
{
echo $file.' is executable';
}
else
{
echo $file.' is not executable';
}
If I execute perl through the terminal, it works fine but when I try to execute through PHP, it is not working.