Module: LSync
- Defined in:
- lib/lsync/version.rb,
lib/lsync.rb,
lib/lsync/run.rb,
lib/lsync/error.rb,
lib/lsync/shell.rb,
lib/lsync/action.rb,
lib/lsync/method.rb,
lib/lsync/script.rb,
lib/lsync/server.rb,
lib/lsync/directory.rb,
lib/lsync/controller.rb,
lib/lsync/shells/ssh.rb,
lib/lsync/tee_logger.rb,
lib/lsync/event_timer.rb,
lib/lsync/event_handler.rb,
lib/lsync/methods/rsync.rb
Overview
Copyright © 2007 Samuel Williams. Released under the GNU GPLv2.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Defined Under Namespace
Modules: EventHandler, Methods, Shells, TeeHelper, VERSION Classes: AbortBackupException, Action, BackupMethodError, BasicController, ConnectionError, CopyController, Directory, DirectoryController, Error, EventTimer, Method, MinimalLogFormat, Script, ScriptError, Server, ServerController, Shell, ShellScriptError, TeeLogger, Timeout
Constant Summary collapse
- CLIENT_CODE =
(Pathname.new(__FILE__).dirname + "shell_client.rb").read
Class Method Summary collapse
-
.run_command(command, logger) ⇒ Object
Run a specific command and output the results to the given logger.
- .run_script(options = {}, &block) ⇒ Object
Class Method Details
.run_command(command, logger) ⇒ Object
Run a specific command and output the results to the given logger.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lsync/run.rb', line 7 def self.run_command(command, logger) logger.info "Running: #{command.to_cmd} in #{Dir.getwd.dump}" process_result = RExec::Task.open(command) do |task| task.input.close pipes = [task.output, task.error] while pipes.size > 0 result = IO.select(pipes) result[0].each do |pipe| if pipe.closed? || pipe.eof? pipes.delete(pipe) next end if pipe == task.output logger.info pipe.readline.chomp elsif pipe == task.error logger.error pipe.readline.chomp end end end end return process_result end |