Skip to content

Instantly share code, notes, and snippets.

@layerssss
Created September 3, 2013 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save layerssss/6418739 to your computer and use it in GitHub Desktop.
Save layerssss/6418739 to your computer and use it in GitHub Desktop.
extract routes info from any kinds of scripts
#!/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