How to run linux commands in php
Hi,
I installed popper utils to convert pdt into html in my ubuntu. In terminal the command pdftohtml -c Desktop/resume.pdf works well but in php <?php echo exec('pdftohtml -c Desktop/resume.pdf'); ?> not works why? Thanks Ramakrishnan |
If you are using a shared hosting server... chances are that you do not have command line access...
If you are trying to run it locally on your computer check the path.... the command may not be executed in your home directory.... Posting the output (if any) would help |
Most probably the path to the file is culprit. While running in a script try to use complete paths.
Use /home/user/Desktop/file.pdf and see if it works. |
I agree with the previous poster that that full pathnames have to be used, but only if the PHP script is initiated via a web browser. If the script is launched from the commandline, then it can use realtive paths as well. In the current case the script will run from your shell only if your working directory is your home directory (assuming that "Desktop" is located there).
|
how to run linux command in php
Quote:
Now i changed that as into exec("/usr/bin/pdftohtml -c /var/www/pdf/resume.pdf /var/www/pdf/resumehtml.html"); still it not works... |
how to run linux command in php
Quote:
i changed it as exec("/usr/bin/pdftohtml -c /var/www/pdf/resume.pdf /var/www/pdf/resumehtml.html"); still it not works but this is works well in terminal |
Ok, just minute, you are putting the commands in quotes while the command should be between the back ticks ``. Change it.
|
how to run linux command in php
Thanks to all for your support,
I corrected that problem since my destination folder has no rights for write. i refered it from http://stackoverflow.com/questions/5...ed-via-browser now output(html files are written to my destination) backticks also works well.. Thanks for full path,backticks information But still one problem output files come with readonly why? i tried to use chmod -R 777 /home/node2/Desktop chmod: changing permissions of `/home/node2/Desktop/resume001.png': Operation not permitted chmod: changing permissions of `/home/node2/Desktop/resume_ind.html': Operation not permitted chmod: changing permissions of `/home/node2/Desktop/resume-1.html': Operation not permitted chmod: changing permissions of `/home/node2/Desktop/resume.html': Operation not permitted this is i get why? these files has owner as www-data how to change readonly Thanks Ramakrishnan |
BTW - this whole little adventure could be a *HUGE* security risk.
ALWAYS be careful about what you let run on the server. VERY careful! IMHO .. PSM |
So it is not possible
|
All times are GMT -5. The time now is 02:47 AM. |