Created
September 3, 2013 01:27
-
-
Save layerssss/6418739 to your computer and use it in GitHub Desktop.
extract routes info from any kinds of scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env coffee | |
if process.argv.length!=5 | |
throw new Error 'Usage: ./getroutes.iced input.rsc RTNAME NEXTHOP' | |
fs = require 'fs' | |
{ | |
exec | |
} = require 'child_process' | |
for route in fs.readFileSync(process.argv[2], 'utf8').match /[\d]+\.[\d]+\.[\d]+\.[\d]+\/[\d]+/g | |
console.log "ip route add table #{process.argv[3]} #{route} #{process.argv[4]}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment