1
I’m trying to use the function exec()
from PHP to run a file. jar (I know it’s not good practice, but it’s the only solution I have at the moment), but I’m not getting good results.
The code in question:
exec(java -jar /home/sistemas/relatorios/jasper_reports/NaturatinsJasperReports/NaturatinsJasperReports.jar 'SELECT * FROM ambiental.vw_fin_fua_ato_azul WHERE id_fua = 31968408 ' '/home/sistemas/relatorios/jasper_reports/jasper/memoria_calculo_azul.jasper' '/home/sistemas/relatorios/memoria_calculo_azul.pdf' '/home/sistemas/relatorios/jasper_reports/NaturatinsJasperReports/desenvolvimento.xml', $output)
Run and simply get empty return. The variable $output
comes set with a Array
and nothing else. However, the command passed by parameter works perfectly when executed via terminal.
Does anyone have any idea about?
Thank you.
No, none. I’ve even switched the path characters to just tiny, but nothing so far.
– timarcosdias
Are not missing the
""
?– Bruno Rozendo
In reality, a string type variable is passed between "".
– timarcosdias
what php log says?
– Bruno Rozendo
Great idea, @Brunorozendo.
Unrecognized option: -jar
Could not create the Java virtual machine.
: not founde/sistemas/relatorios/jasper_reports/naturatins_jasper_reports/naturatins_jasper_reports.jar
: not foundCT * FROM ambiental.vw_fin_fua_ato_azul WHERE id_fua = 31968408 
: not founde/sistemas/relatorios/jasper_reports/jasper/memoria_calculo_azul.jasper
: not founde/sistemas/relatorios/memoria_calculo_azul.pdf
sh: 6: /home/sistemas/relatorios/jasper_reports/naturatins_jasper_reports/desenvolvimento.xml: Permission denied
. I’m trying to solve.– timarcosdias
Solved! The first problem was the permission of the XML file I pass as parameter, the second was that I broke the command on different lines to make it easier to read. Just change the XML permissions and merge the entire command into a single line. Thank you all.
– timarcosdias