Sha256: 7e82e5998b4b6e61caa1bdb81f5df9706f67fc45a10f39561c2b65c3e3956e63
Contents?: true
Size: 1.27 KB
Versions: 4
Compression:
Stored size: 1.27 KB
Contents
#!/usr/bin/env ruby require 'socket' require 'uri' require 'open-uri' require 'optparse' KDWATCH_VERSION=Gem.loaded_specs["kdwatch"].version rescue "unknown-version" loport = 7991 hiport = 7999 match = nil op = OptionParser.new do |opts| opts.banner = <<BANNER Usage: kds [options] [match...] Version: #{KDWATCH_VERSION} (from kdwatch) BANNER opts.on("-v", "--version", "Show version and exit") do |v| puts "kds, from kdwatch #{KDWATCH_VERSION}" exit end opts.on("-h", "--help", "Show option summary and exit") do |v| puts opts exit end opts.on("-fNUM", "--from=NUM", Integer, "Search from port number (#{loport})") do |v| loport = v end opts.on("-tNUM", "--to=NUM", Integer, "Search to port number (#{hiport})") do |v| hiport = v end end op.parse! if ARGV.size != 0 match = ARGV.join(" ") end (loport..hiport).each do |p| url = "http://127.0.0.1:#{p}" URI(url).open do |f| s = f.readpartial(40000) sc = s.scan(/id="title".*?<|Internal server error/) sc.each do |scl| scl.sub!(/id="title">/, "") scl.chomp!('<') puts "#{url} #{scl}" if match && scl.downcase.include?(match.downcase) spawn("open #{url} || xdg-open #{url} || echo @@@ Please open #{url}") end break end end rescue nil end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kdwatch-0.5.5 | bin/kds |
kdwatch-0.5.4 | bin/kds |
kdwatch-0.5.3 | bin/kds |
kdwatch-0.5.2 | bin/kds |