LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-23-2009, 11:30 PM   #1
ramakrishnankt
Member
 
Registered: Nov 2009
Location: India
Posts: 32

Rep: Reputation: 15
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
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 11-23-2009, 11:58 PM   #2
firewiz87
Member
 
Registered: Jan 2006
Distribution: OpenSUSE 11.2, OpenSUSE 11.3,Arch
Posts: 240

Rep: Reputation: 37
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
 
1 members found this post helpful.
Old 11-24-2009, 12:07 AM   #3
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,629

Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
Old 11-24-2009, 12:56 AM   #4
AngTheo789
Member
 
Registered: Sep 2009
Posts: 110

Rep: Reputation: 24
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).
 
Old 11-24-2009, 01:07 AM   #5
ramakrishnankt
Member
 
Registered: Nov 2009
Location: India
Posts: 32

Original Poster
Rep: Reputation: 15
how to run linux command in php

Quote:
Originally Posted by AngTheo789 View Post
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).
Thanks

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...
 
Old 11-24-2009, 01:08 AM   #6
ramakrishnankt
Member
 
Registered: Nov 2009
Location: India
Posts: 32

Original Poster
Rep: Reputation: 15
how to run linux command in php

Quote:
Originally Posted by linuxlover.chaitanya View Post
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.
Thanks
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
 
Old 11-24-2009, 01:13 AM   #7
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,629

Rep: Reputation: Disabled
Ok, just minute, you are putting the commands in quotes while the command should be between the back ticks ``. Change it.
 
1 members found this post helpful.
Old 11-24-2009, 01:25 AM   #8
ramakrishnankt
Member
 
Registered: Nov 2009
Location: India
Posts: 32

Original Poster
Rep: Reputation: 15
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
 
Old 11-24-2009, 10:54 PM   #9
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
2 members found this post helpful.
Old 11-24-2009, 11:16 PM   #10
ramakrishnankt
Member
 
Registered: Nov 2009
Location: India
Posts: 32

Original Poster
Rep: Reputation: 15
So it is not possible
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i run AT commands in linux ? jayarajmohan Linux - General 4 11-24-2009 04:17 PM
able to run root-only commands via php scripts? Swakoo Linux - General 2 01-09-2006 06:01 AM
PHP and Linux commands eggoz Linux - General 2 03-06-2004 03:19 PM
PHP to run Shell commands Gear_freak2000 Linux - Software 4 06-04-2003 05:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration