Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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