Sha256: 366a851d396ce106b97ed36f53d5f9243168db94d1a15eb9dddf58f7e2e3cd89
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
#require 'open4' module Veewee class Shell def self.execute2(command,options = {}) IO.popen("#{command}") { |f| print f } end #pty allows you to gradually see the output of a local command #http://www.shanison.com/?p=415 def self.execute(command, options = {} ) require "pty" begin PTY.spawn( command ) do |r, w, pid| begin r.each { |line| print line;} rescue Errno::EIO end end rescue PTY::ChildExited => e puts "The child process exited!" end end #occassinally fails with 'no child processes def self.execute3(command, options = {} ) defaults= { :port => "22", :exitcode => "0", :user => "root"} options=defaults.merge(options) status = POpen4::popen4(command) do |stdout,stderr,stdin| stdout.each do |line| puts line end end @status=status.to_i if (@status.to_s != options[:exitcode] ) if (options[:exitcode]=="*") #its a test so we don't need to worry else raise "Exitcode was not what we expected" end end end end #Class end #Module
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
veewee-0.1.0a | lib/veewee/shell.rb |