Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I am trying to write a php script that will display all active ethernet interfaces on my Linux server. I am using passthru() to pass shell commands to the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2004
    Posts
    18

    while loop help needed


    Hi,
    I am trying to write a php script that will display all active ethernet interfaces on my Linux server. I am using passthru() to pass shell commands to the system and then sed to trim the output. Now thee might be more than one active interace and the challenge is to have them displayed one at a time.
    THis is what I have done so far:
    Code:
    $int = 0;
    while &#40;$int <=3&#41;;
    &#123;
    passthru&#40;"/sbin/ifconfig eth$int | sed -n '1,2p' "&#41;;
    $int ++;
    &#125;
    THis is the error I get though:

    Fatal error: Maximum execution time of 30 seconds exceeded in /srv/www/htdocs/admn/network.php on line 51

    IS there an obvious flaw in my code or am I missing something else here?

    Thanks

  2. #2
    Linux Guru
    Join Date
    Mar 2003
    Location
    Wisconsin
    Posts
    1,907
    Not a PHP programmer, but I don't think eth$int will work. Perhaps something like eth+$int?

    Jeremy
    Registered Linux user #346571
    "All The Dude ever wanted was his rug back" - The Dude

  3. #3
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    AFAIK, that is the proper notation (eth$int) for your statement. The code looks good...does the user that apache is running as have execute access to /sbin/ifconfig? That could be causing a problem. Any verbose error messages that you can find would also help out.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

Posting Permissions

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