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