Guest User

Untitled

a guest
Feb 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.69 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. ASN="64828"
  4.  
  5. # welcome to the quoting hell
  6. echo "digraph dn42_v4 {" &&
  7. echo "    concentrate = true;" &&
  8. echo "show route primary all where source = RTS_BGP" | birdc -r | awk "
  9.        \$1 == \"BGP.as_path:\" {
  10.                printf(\"    $ASN\");
  11.                for (i = 2; i <= NF; i++ ) {
  12.                        if (j != \$i) {
  13.                                printf(\" -> %s\", \$i);
  14.                                j = \$i
  15.                        }
  16.                }
  17.                if (j != \$NF) {
  18.                        printf(\" -> %s;\n\", \$NF)
  19.                } else {
  20.                        printf(\";\n\")
  21.                }
  22.       }" | sort -u &&
  23. echo "}"
Add Comment
Please, Sign In to add comment