Method: Inspec::Resources::UnixHostProvider#netcat_check_command

Defined in:
lib/inspec/resources/host.rb

#netcat_check_command(hostname, port, protocol) ⇒ Object



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/inspec/resources/host.rb', line 208

def netcat_check_command(hostname, port, protocol)
  if @has_nc
    base_cmd = "nc"
  elsif @has_ncat
    base_cmd = "ncat"
  else
    return
  end

  if protocol == "udp"
    extra_flags = "-u"
  else
    extra_flags = ""
  end

  "echo | #{base_cmd} -v -w 1 #{extra_flags} #{hostname} #{port}"
end