Jump to content
Fórum Script Brasil
  • 0

Nome De Interfaces De Rede


brunomk8

Question

Olá pessoal

Eu preciso fazer um script que pegue o nome das interfaces de rede do FreeBSD. O comando para exibir as interfaces no FreeBSD é o seguinte: /sbin/pfctl -sI | uniq

O resultado é:

lnc

lnc0

lnc1

lo

lo0

notyet

pflog

pflog0

pfsync

pfsync0

plip

plip0

self

Neste caso acima, eu só quero os nomes lnc0 e lnc1. Para isso, preciso fazer um filtro. Sendo assim, eu fiz o seguinte script em php:

#!/usr/local/bin/php -q
<?php
error_reporting(E_ALL);

$ifaces = array("lo", "lo0", "notyet", "plip", "plip0", "self", "carp0", "carp", "pfsync0", "pfsync", "pflog", "pflog0");

$p = popen("/sbin/pfctl -sI | uniq", "r");

while ( ($buff = fgets($p, 256)) ) {
        if (in_array($buff, $ifaces))
                continue;
        echo $buff;
}

pclose($p);

?>

Porém o resultado deste script me retorna o mesmo resultado do comando acima citado.

Alguém sabe porque?

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      651.8k
×
×
  • Create New...