Find the answer to your Linux question:
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 ...
  1. #1
    Just Joined! GatekeeperCruelman's Avatar
    Join Date
    Nov 2008
    Location
    The Netherlands, Wilbertoord
    Posts
    20

    Thumbs down 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;
    ?>

  2. #2
    Just Joined!
    Join Date
    May 2008
    Posts
    42
    U just try this code

    <?php
    $output = shell_exec("ls -lart");
    print $output;
    ?>

  3. #3
    Just Joined! GatekeeperCruelman's Avatar
    Join Date
    Nov 2008
    Location
    The Netherlands, Wilbertoord
    Posts
    20
    Thanks for the response but I found the problem.
    It wasn't php.

    in visudo there is this line:
    Code:
    Defaults    requiretty
    this prevents that you can run the sudo command without an actual interface (like PuTTY or just your actual computer)

    So the problem was the sudo command it self. Everything is working like it should be.
    Thanks again for the response.

  4. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile

    Quote Originally Posted by GatekeeperCruelman View Post
    Thanks for the response but I found the problem.
    It wasn't php.

    in visudo there is this line:
    Code:
    Defaults    requiretty
    this prevents that you can run the sudo command without an actual interface (like PuTTY or just your actual computer)

    So the problem was the sudo command it self. Everything is working like it should be.
    Thanks again for the response.
    Just curious,Why can't you try to open a terminal and execute restart command using option xterm -e
    - 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
    -------------------

  5. #5
    Just Joined! GatekeeperCruelman's Avatar
    Join Date
    Nov 2008
    Location
    The Netherlands, Wilbertoord
    Posts
    20
    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"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...