I've been banging my head against the wall trying to get this going and can't seem to get anywhere.
The goal is to call FOP from php to automate the generation of pdfs.

I can run this command from the command line successfully:
sh /fop/fop -c /fop/SI.conf.xml -fo /fop/temp/test.fo -pdf /fop/temp/test.pdf

When I try to run this from a php script using exec, shell_exec, or passthru:
Command:
export JAVA_HOME="/usr/local/jdk1.5.0_05"
sh /fop/fop -c /fop/SI.conf.xml -fo $foFile -pdf $pdfFile 2>&1

I get the same error:
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/local/jdk1.5.0_05 /bin/java

It would appear that the system is incorrectly appending /bin/java to the JAVA_HOME variable
it should try be executing:
/usr/local/jdk1.5.0_05/bin/java
instead of:
/usr/local/jdk1.5.0_05 /bin/java

I am manually setting JAVA_HOME because if not the error is:
Error: JAVA_HOME is not defined correctly.
We cannot execute java

Anybody have any clues or ideas???

    Not sure, but if you want to run multiple commands via shell_exec(), I think you need to separate them with semi-colons and not newlines. (I'm thinking maybe a newline is being converted to a space or something?

    $cmd = 'export JAVA_HOME="/usr/local/jdk1.5.0_05"[color=red][b];[/b][/color]';
    $cmd .= "sh /fop/fop -c /fop/SI.conf.xml -fo $foFile -pdf $pdfFile 2>&1";
    $result = shell_exec($cmd);
    

    In any case, my suggestion would be to put all the necessary commands into a shell script, then just call that script via shell_exec().

      that did it!
      you just saved my my sore head from some more banging against the wall!
      Thanks nogdog!

        Write a Reply...