Results 1 to 8 of 8

Thread: HowTo : Unix Commands and PHP

  1. #1
    Mentor coltrane's Avatar
    Join Date
    May 2001
    Location
    North Carolina
    Posts
    1,390

    HowTo : Unix Commands and PHP

    <?php passthru("/enter/command/here" ?>



    works like a dream, especially if you want the fortune program to be seen on your webpage...............

  2. #2

    Re: HowTo : Unix Commands and PHP

    nice .. maybe i should start to learn a bit php ..

  3. #3
    Senior Member
    Join Date
    Nov 2001
    Posts
    419

    Re: HowTo : Unix Commands and PHP

    How would I get my system uptime to automatically show on my page?

  4. #4
    Mentor coltrane's Avatar
    Join Date
    May 2001
    Location
    North Carolina
    Posts
    1,390

    Re: HowTo : Unix Commands and PHP

    How would I get my system uptime to automatically show on my page?

    <?php passthru("uptime" ?>

    worked for me

  5. #5

    Re: HowTo : Unix Commands and PHP


    How would I get my system uptime to automatically show on my page?
    with passthru("uptime" you get loads of other stuff that's not quite so useful. I've started using this to break it up:
    Code:
    <?php
    $info = exec("uptime");
    $info = split(",", $info, 7);
    $days = split(" ", $info[0], 4);
    echo "My box has been up for ".$days[3].$info[1];
    ?>
    There's probably a quicker/easier way to do it, but it works


  6. #6

    Re: HowTo : Unix Commands and PHP

    It's probably a heck of a lot better to just read from /proc/uptime. There are two numbers in that file, the first is the number of seconds that your computer has been up. From there it is a simple calculation to work out days, hours, minutes and seconds

  7. #7

    Re: HowTo : Unix Commands and PHP

    How would I use this for shutdown? As far as I can work out, the resulting text with this code will be what the command spits out. But with shutdown, I will have to wait until the computer displays its last message before it is shutdown, right? By that time, everything will be stopped so will no longer work. In turn, I will never get the page to display. Can someone come up with some code just to say whether shutdown executed or not and then display it before the web server is shutdown?

    Cheers

  8. #8
    Mentor coltrane's Avatar
    Join Date
    May 2001
    Location
    North Carolina
    Posts
    1,390

    Re: HowTo : Unix Commands and PHP

    perform the shutdown command

    then ps -ef, grep for the shutdown process.
    if the process exist, then printf "system is shutting down"

    simple

Similar Threads

  1. Suse Commands
    By sophie86 in forum Suse
    Replies: 1
    Last Post: 09-01-2009, 03:50 PM
  2. NIS commands
    By Tamil in forum Linux - Hardware, Networking & Security
    Replies: 0
    Last Post: 01-18-2007, 10:29 PM
  3. VI commands
    By boblucci in forum Linux - General Topics
    Replies: 12
    Last Post: 05-24-2005, 10:13 AM
  4. Shell commands from PHP?
    By tolstoy in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 06-13-2002, 03:25 PM
  5. ljr-bot commands anyone ?
    By civ1492 in forum Linux - Software, Applications & Programming
    Replies: 0
    Last Post: 02-05-2002, 12:50 PM

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
  •