Method: Open4ssh.success

Defined in:
lib/open4ssh.rb

.success(results) ⇒ Bool

Determines whether a list of shell commands has been executed successfully.

Examples:

ecodes = Open4ssh.capture4(
  host: 'remote.host.io',
  user: 'nane',
  key: '/path/to/your/sshkey.pem',
  cmd: [
    "touch helloworld.txt",
    "cat helloworld.txt",
    "echo 'Hello World' >> helloworld.txt",
    "cat helloworld.txt",
    "rm helloworld.txt"
])

if Open4ssh.success(ecodes)
   puts "Success:"
   puts Open4ssh.console(ecodes) # Print collected console outputs of all executed commands
end

Parameters:

  • results (Array<exit_code, std_out, std_err, command>)

    List of returns by executed commands as returned by capture4

Returns:

  • (Bool)

    true, if all exit codes are 0;

  • (Bool)

    false, otherwise



184
185
186
# File 'lib/open4ssh.rb', line 184

def self.success(results)
  results.select { |result| result[0] != 0 }.empty?
end