Method: PSWindows::Exec#get_ip

Defined in:
lib/beaker/host/pswindows/exec.rb

#get_ipObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/beaker/host/pswindows/exec.rb', line 19

def get_ip
  ip = execute("for /f \"tokens=14\" %f in ('ipconfig ^| find \"IP Address\"') do @echo %f").strip
  if ip == ''
    ip = execute("for /f \"tokens=14\" %f in ('ipconfig ^| find \"IPv4 Address\"') do @echo %f").strip
  end
  if ip == ''
    ip = execute("for /f \"tokens=14\" %f in ('ipconfig ^| find \"IPv6 Address\"') do @echo %f").strip
  end
  ip
end