Problem calling shell script from PHP which calls Java
first I have to tell you, that i'm a french guy, so i can make some mistake with my english ;-)
Here is my problem : I want to use a java processor to transform a XML file. I made a shell script wich is working well. But when I execute the shell script from PHP it doesn't work ...
// I tried this
$resultat = shell_exec("sh ".$chemin."script.sh");
// And after this
$resultat = shell_exec("java -jar ". $jar ." -s:".$source." -xsl:".$xslt);
The file "script.sh" contains this :
JAR='lib/saxon/saxon9he.jar'
SOURCE='temp/fichier_xml.xml'
RESULT开发者_开发百科="temp/output.xml"
XSLT="xml_to_xml.xsl"
java -jar $JAR -s:$SOURCE -xsl:$XSLT
I think that's a problem with JAVA ... But I can not resolve this !!
If you have an idea to help me,
Thanks
Try using the script in backticks i.e. ``
shell_exec('cd ' . $chemin . ' & sh script.sh');
- Go to your $chemin dir
- Then run your script, as java need correct pathes
精彩评论