LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-27-2007, 05:43 PM   #1
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
executing shell commands in PHP


I have used exec function to obtain a list of available print jobs in cups which worked very nice. But now I want to release held jobs using lp -i job-id -H reuse

but I can't do that the same way I did for finding available jobs.

I m wondering if there is any function that can execute anything. I even tried to make a directory, but it didn't do anything.

Any idea?
 
Old 08-27-2007, 06:27 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by mohtasham1983 View Post
but I can't do that the same way I did for finding available jobs.
Why not?
What happens when you try?
What error?

Are you running it through a webserver? If so, the webserver is probably running under a system account with not too much permissions on you system... Could permissions be the problem?

Last edited by Hko; 08-27-2007 at 07:05 PM.
 
Old 08-27-2007, 11:27 PM   #3
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
It just doesn't do anything when I write exec("mkdir /home/myname/new");

I have full control over server with all permissions.
 
Old 08-29-2007, 03:09 PM   #4
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86; Gentoo PPC; Gentoo Sparc64; FreeBSD; OS X; Solaris
Posts: 3,731
Blog Entries: 4

Rep: Reputation: 68
If you are running in safe mode you can only exec programs located in "safe_mode_exec_dir". Check your php.ini.
 
Old 09-13-2007, 03:48 AM   #5
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
I just checked phpinfo(). It states that safe mode is off.

I would like to mention that I can create a directory if it is inside apache root directory. like mkdir new_dir
 
Old 09-14-2007, 01:12 AM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
That's because any dir under the Apache docs area is owned by the Apache user (usually apache or 'nobody' or httpd) .
/home/myname would be owned by the user 'myname'
 
Old 09-14-2007, 03:36 AM   #7
myrmidon
Member
 
Registered: May 2005
Distribution: redhat 9 , fedora 5,6,7,DSL,Debian 3, mandrake 9.2 , knoppix 3.8, red hat 7.3
Posts: 38

Rep: Reputation: 15
in this mode yup can create dirs ONLY in your web directory .

like /var/www/html/

if your shell command need to be executed by apache server, you will need to add the apache user to sudoer.

AND you will have to add the exact command(with all parameters) to sudo file. after that the command can be executet via php with sudo prefix.
 
Old 09-14-2007, 11:04 AM   #8
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
Basically I was adding nobody user to sudoers file. I did a whoaom I command and it told me that apache user is www-data.

Everything works fine now.

Thanks a lot.
 
  


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
Executing system commands in a php script atiq Linux - Server 2 02-26-2007 09:45 AM
Executing shell commands through PHP!!! Richtown Linux - Newbie 6 04-12-2006 02:57 PM
[PHP] Sending shell commands from PHP pEeDy Programming 4 11-04-2005 08:06 PM
executing shell commands in c++ true_atlantis Programming 2 10-01-2004 04:53 PM


All times are GMT -5. The time now is 09:31 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration