Skip to content

Instantly share code, notes, and snippets.

View wyrmiyu's full-sized avatar

Sandi Wallendahl wyrmiyu

  • Red Hat
  • Finland
View GitHub Profile
@ashrithr
ashrithr / port_open.rb
Last active December 18, 2023 15:15
check if port is open on a remote host
#!/usr/bin/env ruby
require 'socket'
require 'timeout'
unless ARGV.length == 2
abort "Usage: ruby #{__FILE__} HOST PORT"
end
def port_open?(ip, port, seconds=1)
# => checks if a port is open or not on a remote host
Timeout::timeout(seconds) do