Module: PSWindows::Exec

Includes:
Beaker::CommandFactory
Included in:
Host
Defined in:
lib/beaker/host/pswindows/exec.rb

Constant Summary collapse

ABS_CMD =
'c:\\\\windows\\\\system32\\\\cmd.exe'
CMD =
'cmd.exe'

Instance Attribute Summary

Attributes included from Beaker::CommandFactory

#assertions

Instance Method Summary collapse

Methods included from Beaker::CommandFactory

#execute, #fail_test

Instance Method Details

#echo(msg, abs = true) ⇒ Object



11
12
13
# File 'lib/beaker/host/pswindows/exec.rb', line 11

def echo(msg, abs=true)
  (abs ? ABS_CMD : CMD) + " /c echo #{msg}"
end

#get_ipObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/beaker/host/pswindows/exec.rb', line 27

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

#pathObject



23
24
25
# File 'lib/beaker/host/pswindows/exec.rb', line 23

def path
  'c:/windows/system32;c:/windows'
end

#rebootObject



4
5
6
# File 'lib/beaker/host/pswindows/exec.rb', line 4

def reboot
  exec(Beaker::Command.new("shutdown /r /t 0"), :expect_connection_failure => true)
end

#rm_rf(path) ⇒ Object



19
20
21
# File 'lib/beaker/host/pswindows/exec.rb', line 19

def rm_rf path
  execute("del /s /q #{path}")
end

#touch(file, abs = true) ⇒ Object



15
16
17
# File 'lib/beaker/host/pswindows/exec.rb', line 15

def touch(file, abs=true)
  (abs ? ABS_CMD : CMD) + " /c echo. 2> #{file}"
end