Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    while loop help needed

    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:
    $int = 0;
    while &#40;$int <=3&#41;;
    passthru&#40;"/sbin/ifconfig eth$int | sed -n '1,2p' "&#41;;
    $int ++;
    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?


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

    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
    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

  4. $spacer_open

Posting Permissions

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