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, #to_xml

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



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/CommandManager.rb', line 250

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