Results 1 to 5 of 5
Hello all,
I'm trying to execute a few commands on linux with php from a webbrowser.
I found the commands and the php functions, but for some reason the output ...
- 01-13-2009 #1
execute command with php
Hello all,
I'm trying to execute a few commands on linux with php from a webbrowser.
I found the commands and the php functions, but for some reason the output will not come on the screen, but when I use the same command for that user in the commandline I get output
I changed with "visudo" so that the apache user can use the sudo commands.
This is the code I tried:
PHP Code:<?php
$result = shell_exec("sudo -u root /etc/init.d/yum-cron restart");
print $result;
?>
- 01-14-2009 #2Just Joined!
- Join Date
- May 2008
- Posts
- 42
U just try this code
<?php
$output = shell_exec("ls -lart");
print $output;
?>
- 01-14-2009 #3
Thanks for the response but I found the problem.
It wasn't php.
in visudo there is this line:
this prevents that you can run the sudo command without an actual interface (like PuTTY or just your actual computer)Code:Defaults requiretty
So the problem was the sudo command it self. Everything is working like it should be.
Thanks again for the response.
- 01-16-2009 #4
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 01-16-2009 #5
I'm working on a project and a normal user need to access the linux through a webbrowser. Most of those users are used to windows, or doesn't have much experience with a computer at all. So I'm making an user-friendly interface where they can do a few actions that are needed to configure a few parts in Linux and a few programs.
We don't wanna do every single action for every user (I'm talking about thousands of users)
We also want it too be easy installed, or better no install.
I hope this answer will explain the "Why"


Reply With Quote
