SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script to run a unix command via browser?

    I need to run a few unix commands via my browser.. does anyone have a script that allows this?

    Specifically, I need to kill a runaway process when they occur and I don't always have access to SSH. I'd love a script that could give me a simple text box where I can type something like "kill [pid]", press submit and the results are displayed in another box/frame/iframe.

    Thanks!

  2. #2
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's unlikely that you can do it, because kill needs to run at the same or greater privellege level than the process you are trying to kill. As you'd be running the script as the web server user (or if you're using SuExec then as the owner of the account you're running the script from). Of course you could set a site to run SuExec as root - but Do Not do that as you're just asking for some serious trouble.

    Thanks,
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  3. #3
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Karl
    It's unlikely that you can do it, because kill needs to run at the same or greater privellege level than the process you are trying to kill. As you'd be running the script as the web server user (or if you're using SuExec then as the owner of the account you're running the script from). Of course you could set a site to run SuExec as root - but Do Not do that as you're just asking for some serious trouble.

    Thanks,
    The scripts I would need to kill would in fact be running as the same user as the "psuedo shell" that I need.

    No problems... Do you know where I can find something like this?

  4. #4
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try a script like this, then:
    PHP Code:
    <?php
    if(isset($_POST['submit']))
      {
      
    system($_POST['command']);
      }
    else
      {
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
      <input typ="text" name="command"><br>
      <input type="submit" name="submit" value="submit">
    </form>
    <?php
      
    }
    ?>
    untested.

    Aaron
    Aaron Brazell
    Technosailor



  5. #5
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just don't leave that script online

    cd / | rm -rf *

    Chrispian H. Burks
    Nothing To Say

  6. #6
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Amen to that! I didn't think I had to put a disclaimer like that on it seems Karl summed up the securtiy issues pretty good.

    Aaron
    Aaron Brazell
    Technosailor



  7. #7
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I figured it wouldn't hurt to say it outloud with a potent example
    Chrispian H. Burks
    Nothing To Say


Bookmarks

Posting Permissions

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