LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to execute shell commands that require root password from PHP ? (http://www.linuxquestions.org/questions/linux-software-2/how-to-execute-shell-commands-that-require-root-password-from-php-816561/)

newbie_0404 06-26-2010 08:51 PM

How to execute shell commands that require root password from PHP ?
 
Hello,
I am kinda new with php. I am developing a web-interface for an application that sometimes needs root privs. Editting /etc/sudoers is not an option since the web interface needs to be portable to other users when they install my application. Is there any workaround ?

PHP Code:

php code:

$command "./script.sh /dev/$DISKNAME &";
$shellOutput shell_exec($command); 

Code:

script:

#!/bin/bash
DISK=$1

sudo -u root -S ./a.out $DISK < /path/to/a/tmpfile/that/contains/root/password > check.log

check.log gets created. But the results of ./a.out dont show up in the log file. And the script works fine when run from the terminal. User doesnt have to enter password. But from PhP the log file is created and then the script exits with exit code 1. Is there anything i am doing wrong ? Anyone aware of how to achieve what I want to do ?

Any help would be highly appreciated.

newbie_0404 06-27-2010 02:31 AM

anyone?

MTK358 06-27-2010 09:16 AM

It's a bad idea to bump it yourself so soon because it disables the auto-bumping feature and also takes the thread of the zero-reply list.


All times are GMT -5. The time now is 11:32 AM.