Monday, November 22, 2010

Problem executing shell command from PHP script?

I want to execute a shell script which is located at /usr/local/bin/ on my server. This script converts doc files to pdf. Now from the command mode the conversion is happening well. I have to cd (change directory) to that location and then execute the following command:-



hpm_oo2.bin /path/to/input/file/content_238.doc /path/to/output/file/output4.pdf



Even though the command window shows this:-

======================================?br>


23-Dec-2008 05:11:32 net.sf.jooreports.openoffice.connection.?connect

INFO: connected

23-Dec-2008 05:11:32 net.sf.jooreports.openoffice.connection.?disposing

INFO: disconnected



======================================?br>
I get the output pdf file in the path/to/output/file.



Now I want to do the same conversion from PHP code. I wrote the following code:-



======================================?br>
chdir('/usr/local/bin/');

echo ';path';.getcwd().';%26lt;br%26gt;';;

exec(';hpm_oo2.bin /home/vjpsych/domains/vjpsych.ie/public_?/home/vjpsych/domains/vjpsych.ie/public_?



The output shows:-

path/usr/local/bin/ but the conversion is not taking place. How do I make the conversion? What is the error in my code? Please help.Problem executing shell command from PHP script?
Try running the shell scripts on the command-line on your own machine. That may help you catch the errors more quickly.



Other than that advice, I can't help sorry :S
  • cute hair
  • use hair removal cream
  • No comments:

    Post a Comment