Module: Windows::Exec
Constant Summary collapse
- ABS_CMD =
'c:\\\\windows\\\\system32\\\\cmd.exe'
- CMD =
'cmd.exe'
Instance Attribute Summary
Attributes included from Beaker::CommandFactory
Instance Method Summary collapse
- #echo(msg, abs = true) ⇒ Object
- #get_ip ⇒ Object
- #path ⇒ Object
-
#ping(target, attempts = 5) ⇒ Boolean
Attempt to ping the provided target hostname.
- #reboot ⇒ Object
- #touch(file, abs = true) ⇒ Object
Methods included from Beaker::CommandFactory
Instance Method Details
#echo(msg, abs = true) ⇒ Object
11 12 13 |
# File 'lib/beaker/host/windows/exec.rb', line 11 def echo(msg, abs=true) (abs ? ABS_CMD : CMD) + " /c echo #{msg}" end |
#get_ip ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/beaker/host/windows/exec.rb', line 23 def get_ip ip = execute("ipconfig | grep -i 'IP Address' | cut -d: -f2 | head -1").strip if ip == '' ip = execute("ipconfig | grep -i 'IPv4 Address' | cut -d: -f2 | head -1").strip end if ip == '' ip = execute("ipconfig | grep -i 'IPv6 Address' | cut -d: -f2 | head -1").strip end ip end |
#path ⇒ Object
19 20 21 |
# File 'lib/beaker/host/windows/exec.rb', line 19 def path 'c:/windows/system32;c:/windows' end |
#ping(target, attempts = 5) ⇒ Boolean
Attempt to ping the provided target hostname
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/beaker/host/windows/exec.rb', line 38 def ping target, attempts=5 try = 0 while try < attempts do result = exec(Beaker::Command.new("ping -n 1 #{target}"), :accept_all_exit_codes => true) if result.exit_code == 0 return true end try+=1 end result.exit_code == 0 end |