5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/checkpoint_knocker.rb', line 5
def knock(options={})
host = options[:host]
port = options[:port]
user = options[:user]
pass = options[:pass]
begin
h = Net::Telnet.new('Host' => host,
'Port' => port)
h.waitfor(/User:/) { |c| print c }
h.print("#{user}\n") { |c| print c }
h.waitfor(/password:/) { |c| print c }
h.print("#{pass}\n") { |c| print c }
h.waitfor(/authenticated/) { |c| print c }
h.print("1") { |c| print c }
h.waitfor(/authorized/) { |c| print c }
h.close
rescue Errno::ECONNRESET
end
end
|