Class: CMD::CALL

Inherits:
Object
  • Object
show all
Extended by:
Utils
Defined in:
lib/cmd.rb

Class Method Summary collapse

Methods included from Utils

execute_command, print_error

Class Method Details

.clearObject



22
23
24
25
# File 'lib/cmd.rb', line 22

def self.clear
  cmd_clear = SYSll::VERIFY.os == :windows ? 'cls' : 'clear'
  execute_command(cmd_clear, "clear_failed")
end

.kill_process(pid, flag = nil) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/cmd.rb', line 46

def self.kill_process(pid, flag = nil)
  cmd_kill = if SYSll::VERIFY.os == :windows
                flag.nil? ? "taskkill /PID #{pid}" : "taskkill /PID #{pid} #{flag}"
             else 
                flag.nil? ? "kill #{pid}" : "kill #{flag} #{pid}"
             end
  execute_command(cmd_kill, "kill_process_failed", pid: pid)
end

.list_files(flags = nil) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/cmd.rb', line 27

def self.list_files(flags = nil)
  cmd_lf = if SYSll::VERIFY.os == :windows
            'dir'
           else
             flags.nil? ? "ls" : "ls #{flags}"
           end
  execute_command(cmd_lf, "list_files_failed")
end

.network_infoObject



36
37
38
39
# File 'lib/cmd.rb', line 36

def self.network_info
  cmd_netinf = SYSll::VERIFY.os == :windows ? 'ipconfig' : 'ifconfig'
  execute_command(cmd_netinf, "network_info_failed")
end

.process_infoObject



41
42
43
44
# File 'lib/cmd.rb', line 41

def self.process_info
  cmd_process = SYSll::VERIFY.os == :windows ? 'tasklist' : 'ps aux'
  execute_command(cmd_process, "process_info_failed")
end

.sys(flags = nil) ⇒ Object



55
56
57
58
# File 'lib/cmd.rb', line 55

def self.sys(flags = nil)
  cmd_sys = SYSll::VERIFY.os == :windows ? "systeminfo" : flags.nil? ? "uname" : "uname #{flags}"
  execute_command(cmd_sys, "sys_failed")
end