Skip to content

Instantly share code, notes, and snippets.

@shanecelis
Created May 15, 2010 10:13
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 shanecelis/402125 to your computer and use it in GitHub Desktop.
Save shanecelis/402125 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# parse-kevin
if ARGV.length != 2 then
puts "usage: parse-kevin <listen-for> <input>"
exit(1)
end
pattern = ARGV[0]
infile = File.new(ARGV[1], "r")
readingRightListen = false
infile.each { |line|
if line =~ /^listen\s+(\S+)/ then
#puts $1
if pattern == $1 then
#puts "good"
readingRightListen = true
else
readingRightListen = false
end
end
if readingRightListen and line =~ /^\s*server\s+\S+\s+(\S+):/ then
puts $1
end
}
infile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment