28
|
1 #!/usr/bin/php |
|
2 <?php |
|
3 $sock = fsockopen('localhost', 2605); |
|
4 fread($sock, 1024); |
|
5 fwrite($sock, "insecure\n"); |
|
6 fwrite($sock, "show ip bgp paths\n"); |
|
7 fwrite($sock, "quit\n"); |
|
8 while (!feof($sock)) { |
|
9 $line = stream_get_line($sock, 1024, "\r\n"); |
|
10 if ($line === NULL || $line === FALSE) break; |
|
11 if (!strlen($line) || $line[0] != '[') continue; |
|
12 $pos = strpos($line, ') '); |
|
13 if ($pos === FALSE) continue; |
|
14 if ($pos == strlen($line) - 2) continue; |
|
15 print(substr($line, $pos+2)."\n"); |
|
16 } |