Sto provando ad eseguire un file Jar nel backend del mio codice php. Ma non sto ottenendo l'output desiderato. C'è un file jar che viene eseguito in background e restituisce il Page Rank di qualsiasi parola chiave e Dominio assegnato ad esso. Allego il codice, per favore suggeriscimi qualsiasi soluzione, perché quando lo eseguo sul terminale, sta dando un output corretto.Come eseguire un comando shell tramite il codice PHP?
Ecco il codice:
<?php
set_time_limit(0);
function returnJarPath()
{
$jarPath = $_SERVER['DOCUMENT_ROOT'] . "myFolder/tools_new/includes/Rank.jar";
return $jarPath;
}
$jar = returnJarPath();
$command = "java -jar $jar aspdotnet/microsoft.com";//Passing the Argument to the Jar file.
$shellOutput = shell_exec($command);
print "The Shell Output is : " ; var_dump($shellOutput);print "<br />";
exec($command,$executeCommmand);
print "The Exec returns the value : " ; var_dump($executeCommmand);print "<br />";
passthru($command,$passthruCommand);
print "The Passthru returns the value : " . $passthruCommand. "<br />";
?>
Ho appena controllato log degli errori di apache e l'ultimo errore che ho trovato è stato:
sh: java: command not found
Ma come ho già detto, sto usando lo stesso comando tramite SSH per eseguire il comando Java. Quindi non c'è alcuna possibilità di non avere JAVA installato sul server. Please help me out di questo pasticcio ...
Stai ottenendo alcun output? Qualche errore? – Buggabill
@Buggabill: No. Non tramite Php ma sto ottenendo l'output corretto tramite Terminale (Console). –