Class: Proclib::Commands::Ssh
- Inherits:
-
Base
- Object
- Base
- Proclib::Commands::Ssh
show all
- Defined in:
- lib/proclib/commands/ssh.rb
Constant Summary
collapse
- SSHError =
Class.new(Error)
Constants inherited
from Base
Base::NotYetRunning, Base::NotYetTerminated, Base::STDIN_BUF_SIZE
Instance Method Summary
collapse
Constructor Details
#initialize(ssh_session:, **args) ⇒ Ssh
Returns a new instance of Ssh.
10
11
12
13
|
# File 'lib/proclib/commands/ssh.rb', line 10
def initialize(ssh_session:, **args)
@ssh_session = ssh_session
super(**args)
end
|
Instance Method Details
#cmdline ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/proclib/commands/ssh.rb', line 36
def cmdline
if !run_dir.nil?
"cd #{run_dir}; #{super}"
else
super
end
end
|
#spawn ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/proclib/commands/ssh.rb', line 15
def spawn
write_pipes
open_channel do |channel|
channel.exec(cmdline) do |_, success|
raise SSHError, "Command Failed" unless success
if !stdin.nil?
while msg = stdin.read(STDIN_BUF_SIZE)
channel.send_data(msg)
end
channel.eof!
end
end
end
end
|
#wait ⇒ Object
32
33
34
|
# File 'lib/proclib/commands/ssh.rb', line 32
def wait
ssh_session.loop
end
|