Sha256: 313a42e00a39ea2bf664d7330690a1303036a91ecd487931499fff09142a1085

Contents?: true

Size: 793 Bytes

Versions: 5

Compression:

Stored size: 793 Bytes

Contents

module PSWindows::Exec
  include Beaker::CommandFactory

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

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

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

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

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

  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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
beaker-2.9.0 lib/beaker/host/pswindows/exec.rb
beaker-2.8.0 lib/beaker/host/pswindows/exec.rb
beaker-2.7.1 lib/beaker/host/pswindows/exec.rb
beaker-2.7.0 lib/beaker/host/pswindows/exec.rb
beaker-2.6.0 lib/beaker/host/pswindows/exec.rb