link7722 Posted January 26, 2011 Share Posted January 26, 2011 Hi, I am trying to use php to pass some commands to my linux box.From my webpage I am using the shell_exec function which is working OK but for some administrative tasks in linux I must have root access. As I am sending the commands from the webpage the apache user is used and so I am not allowed to do several tasks. I have also tried to use a bash script to pass the commands but with no result. Any ideas ? Link to comment https://forums.phpfreaks.com/topic/225729-php-and-linux-command-line/ Share on other sites More sharing options...
Cagecrawler Posted January 26, 2011 Share Posted January 26, 2011 You can use the sudo command to get superuser access. There's multiple ways to get sudo to run silently if that's what you need. Link to comment https://forums.phpfreaks.com/topic/225729-php-and-linux-command-line/#findComment-1165457 Share on other sites More sharing options...
link7722 Posted January 26, 2011 Author Share Posted January 26, 2011 I already tried sudo but I get the following error in apache error.log: sudo can only be run in tty Thanks Link to comment https://forums.phpfreaks.com/topic/225729-php-and-linux-command-line/#findComment-1165465 Share on other sites More sharing options...
Cagecrawler Posted January 26, 2011 Share Posted January 26, 2011 You can run the visudo command and comment out the line that says Defaults requiretty Link to comment https://forums.phpfreaks.com/topic/225729-php-and-linux-command-line/#findComment-1165468 Share on other sites More sharing options...
link7722 Posted January 26, 2011 Author Share Posted January 26, 2011 Now the error log responds with no tty present and no askpass program . I am using the latest Centos version. Link to comment https://forums.phpfreaks.com/topic/225729-php-and-linux-command-line/#findComment-1165500 Share on other sites More sharing options...
link7722 Posted January 26, 2011 Author Share Posted January 26, 2011 OK solved. I needed to change the sudoers file for the apache user Link to comment https://forums.phpfreaks.com/topic/225729-php-and-linux-command-line/#findComment-1165507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.