Sha256: 1f52b40c49bbac56969baabad991d6d33475fd8d069114900bace7b935532cff

Contents?: true

Size: 1.35 KB

Versions: 37

Compression:

Stored size: 1.35 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 { }      
                  #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

37 entries across 37 versions & 2 rubygems

Version Path
HeSYINUvSBZfxqA-veewee-0.203.3 lib/veewee/shell.rb
HeSYINUvSBZfxqA-veewee-0.203.2 lib/veewee/shell.rb
HeSYINUvSBZfxqA-veewee-0.203.1 lib/veewee/shell.rb
veewee-0.2.3 lib/veewee/shell.rb
veewee-0.2.2 lib/veewee/shell.rb
veewee-0.2.1 lib/veewee/shell.rb
HeSYINUvSBZfxqA-veewee-0.2.0.2 lib/veewee/shell.rb
veewee-0.2.0 lib/veewee/shell.rb
veewee-0.1.29 lib/veewee/shell.rb
veewee-0.1.28 lib/veewee/shell.rb
veewee-0.1.27 lib/veewee/shell.rb
veewee-0.1.26 lib/veewee/shell.rb
veewee-0.1.25 lib/veewee/shell.rb
veewee-0.1.24 lib/veewee/shell.rb
veewee-0.1.23 lib/veewee/shell.rb
veewee-0.1.22 lib/veewee/shell.rb
veewee-0.1.21 lib/veewee/shell.rb
veewee-0.1.20 lib/veewee/shell.rb
veewee-0.1.19 lib/veewee/shell.rb
veewee-0.1.18 lib/veewee/shell.rb