LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   executing shell commands in PHP (https://www.linuxquestions.org/questions/programming-9/executing-shell-commands-in-php-580259/)

mohtasham1983 08-27-2007 05:43 PM

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?

Hko 08-27-2007 06:27 PM

Quote:

Originally Posted by mohtasham1983 (Post 2872644)
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?

mohtasham1983 08-27-2007 11:27 PM

It just doesn't do anything when I write exec("mkdir /home/myname/new");

I have full control over server with all permissions.

bulliver 08-29-2007 03:09 PM

If you are running in safe mode you can only exec programs located in "safe_mode_exec_dir". Check your php.ini.

mohtasham1983 09-13-2007 03:48 AM

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

chrism01 09-14-2007 01:12 AM

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'

myrmidon 09-14-2007 03:36 AM

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.

mohtasham1983 09-14-2007 11:04 AM

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.


All times are GMT -5. The time now is 10:16 AM.