Module: Cirrus::SCP

Extended by:
SCP
Included in:
SCP
Defined in:
lib/cirrus/scp.rb

Defined Under Namespace

Classes: SCPUnavailable

Instance Method Summary collapse

Instance Method Details

#connect(host, username) ⇒ Object

Opens an SCP connection and yields it so that you can download and upload files.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cirrus/scp.rb', line 12

def connect(host, username)
  Cirrus::SSH.connect(host, username) do |connection|
    scp = Net::SCP.new(connection)
    return yield scp
  end
rescue Net::SCP::Error => e
  # If we get the exit code of 127, then this means SCP is unavailable.
  raise SCPUnavailable if e.message =~ /\(127\)/

  # Otherwise, just raise the error up
  raise e
end