SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Accessing unix system via PHP

    Hi,

    I'm trying to make a web bassed application so that I could access the network interfac and get the status if it is up or down. And if it is down set ti tu up and or change the IP address.

    Could this be done via a php apllication?

    Thanks for any infomation about this.

    Best regards

  2. #2
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would have to write a shell script to do this and you could call the shell script using the exec function: http://us3.php.net/function.exec

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aha, ok cool.

    Thank you for the info.
    I've been reading up on this now that I know what to look for and to read info I could just use a code like this.

    Code:
    <?php
    $dev = "eth1";
    $show = exec("ifconfig $dev");
    print $show;
    ?>
    Of course I would have to filter out the data I woudl like to display but I think I could work with it.

    And the something simmilar for the UP or DONW comands.

    Am I right?

    Thanks for the help again.

  4. #4
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Success I got it working simmilar to the code above accept I had to insert the full path to ifconfig and used the shell_exec() insted of exec().

    Now if I've got the string that prints out the information, how can devide the information and get the data I need separatd. Is there a function that I could use to find a part of a string and then put the data behind it into an variable.

    Thanks for the help.


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
  •