class Bcome::Ssh::ScriptExec
Public Class Methods
execute(server, path_to_script)
click to toggle source
# File lib/objects/ssh/script_exec.rb, line 6 def execute(server, path_to_script) executor = new(server, path_to_script) executor.execute end
new(server, path_to_script)
click to toggle source
# File lib/objects/ssh/script_exec.rb, line 12 def initialize(server, path_to_script) @server = server @path_to_script = path_to_script @ssh_driver = server.ssh_driver @output_string = '' end
Public Instance Methods
execute()
click to toggle source
# File lib/objects/ssh/script_exec.rb, line 19 def execute command = execute_command pretty_print(command) command end
execute_command()
click to toggle source
# File lib/objects/ssh/script_exec.rb, line 25 def execute_command raise Bcome::Exception::OrchestrationScriptDoesNotExist, @path_to_script unless File.exist?(@path_to_script) execute_script_command = "#{@ssh_driver.ssh_command} \"bash -s\" < #{@path_to_script}" command = ::Bcome::Command::Local.run(execute_script_command) command end
output_append(output_string)
click to toggle source
# File lib/objects/ssh/script_exec.rb, line 40 def output_append(output_string) @output_string += "#{@output_string}#{output_string}" end
pretty_print(command)
click to toggle source
# File lib/objects/ssh/script_exec.rb, line 33 def pretty_print(command) output_append("\n(#{@server.namespace})$".terminal_prompt + "> ./#{@path_to_script} - \s#{command.pretty_result}\n") output_append(command.stdout) # append stderr output_append "\nSTDERR: #{command.stderr}" if command.failed? puts "\n\n#{@output_string}\n\n" end