Class: Hydra::SSH
- Inherits:
-
Object
- Object
- Hydra::SSH
- Includes:
- MessagingIO, Open3
- Defined in:
- lib/hydra/ssh.rb
Overview
Read and write with an ssh connection. For example:
@ssh = Hydra::SSH.new(
'localhost', # connect to this machine
'/home/user', # move to the home directory
"ruby hydra/test/echo_the_dolphin.rb" # run the echo script
)
@message = Hydra::Messages::TestMessage.new("Hey there!")
@ssh.write @message
puts @ssh.gets.text
=> "Hey there!"
Note that what ever process you run should respond with Hydra messages.
Instance Method Summary collapse
-
#initialize(connection_options, directory, command) ⇒ SSH
constructor
Initialize new SSH connection.
Methods included from MessagingIO
Constructor Details
#initialize(connection_options, directory, command) ⇒ SSH
Initialize new SSH connection. The single parameters is passed directly to ssh for starting a connection. So you can do:
Hydra::SSH.new('localhost')
Hydra::SSH.new('[email protected]')
Hydra::SSH.new('-p 3022 [email protected]')
etc..
26 27 28 29 30 |
# File 'lib/hydra/ssh.rb', line 26 def initialize(, directory, command) @writer, @reader, @error = popen3("ssh #{}") @writer.write("cd #{directory}\n") @writer.write(command+"\n") end |