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? |
Quote:
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? |
It just doesn't do anything when I write exec("mkdir /home/myname/new");
I have full control over server with all permissions. |
If you are running in safe mode you can only exec programs located in "safe_mode_exec_dir". Check your php.ini.
|
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 |
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' |
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. |
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. |