Add some efficiency improvements
parent
d91ef7c9dc
commit
85b09a162a
|
@ -110,11 +110,9 @@ module System
|
|||
def get_listening_services(portsonly = false)
|
||||
services = {}
|
||||
begin
|
||||
full = cmd_exec('netstat -tulpn')
|
||||
full = cmd_exec('netstat -tulpn').to_s
|
||||
raise "You must be root to get listening ports" if full.include? '(No info could be read'
|
||||
lines = full.split("\n").size
|
||||
cmd = "netstat -tulpn | tail -n #{lines - 2}"
|
||||
full = cmd_exec(cmd)
|
||||
full = full[2..-1]
|
||||
full.delete!(':') # Only happens when getting services
|
||||
|
||||
if portsonly
|
||||
|
|
Loading…
Reference in New Issue