Skip to content

Instantly share code, notes, and snippets.

@jonuts
Created July 6, 2009 16:19
Show Gist options
  • Save jonuts/141518 to your computer and use it in GitHub Desktop.
Save jonuts/141518 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
abort("usage: #{__FILE__} START_PORT END_PORT") unless ARGV.size == 2
START_PORT = ARGV.shift.to_i
END_PORT = ARGV.shift.to_i
loop do
used_ports = []
START_PORT.upto(END_PORT).each do |port|
scan = `lsof -i :#{port}`.chomp
used_ports << port unless scan.empty?
end
break if used_ports.empty?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment