Class: RemotesCommand

Inherits:
SSHCommand show all
Defined in:
lib/CommandManager.rb

Constant Summary

Constants inherited from GenericCommand

GenericCommand::ERROR_CLOSE, GenericCommand::ERROR_OPEN

Instance Attribute Summary

Attributes inherited from SSHCommand

#host

Attributes inherited from GenericCommand

#code, #command, #stderr, #stdout

Class Method Summary collapse

Methods inherited from SSHCommand

#initialize

Methods inherited from GenericCommand

#get_error_message, #initialize, #log, #run

Constructor Details

This class inherits a constructor from SSHCommand

Class Method Details

.run(command, host, remote_dir, logger = nil, stdin = nil, retries = 0, timeout = nil) ⇒ Object

Creates a command and runs it



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/CommandManager.rb', line 227

def self.run(command, host, remote_dir, logger=nil, stdin=nil, retries=0, timeout=nil)
    cmd_file = command.split(' ')[0]

    cmd_string = "'if [ -x \"#{cmd_file}\" ]; then #{command}; else\
                          exit #{MAGIC_RC}; fi'"

    cmd = self.new(cmd_string, host, logger, stdin, timeout)
    cmd.run

    while cmd.code != 0 and retries != 0
        if cmd.code == MAGIC_RC
            update_remotes(host, remote_dir, logger)
        end

        sleep 1
        cmd.run
        retries = retries - 1
    end

    cmd
end