Class: Net::SSH::Locate::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ssh/locate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#agentPIDObject (readonly)

Returns the value of attribute agentPID.



47
48
49
# File 'lib/net/ssh/locate.rb', line 47

def agentPID
  @agentPID
end

#agentSocketObject (readonly)

Returns the value of attribute agentSocket.



47
48
49
# File 'lib/net/ssh/locate.rb', line 47

def agentSocket
  @agentSocket
end

#foundObject (readonly)

Returns the value of attribute found.



47
48
49
# File 'lib/net/ssh/locate.rb', line 47

def found
  @found
end

Instance Method Details

#found?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/net/ssh/locate.rb', line 64

def found?
  @found
end

#scanObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/net/ssh/locate.rb', line 49

def scan
  @found = false
  procs = Sys::ProcTable.ps.select do 
    |p|
    (p.cmdline =~ /ssh-agent/) && !(p.cmdline =~ /--session=ubuntu/) && !(p.state=='Z')
  end
  return if procs.empty?
  p=procs.first
  p.cmdline =~ /ssh-agent\s-a ([-.a-zA-Z0-9_\/]+)/
  return if !$~
  @found = true
  @agentSocket = $1
  @agentPID = p.pid
end