Sha256: 8fb55588ac2bf1c560d66a31754ee27cf3151c61d96d68ff6e0f0bfd1c7b9cd8

Contents?: true

Size: 922 Bytes

Versions: 26

Compression:

Stored size: 922 Bytes

Contents

require 'rubygems'
require 'stringio'
require 'posix/spawn'

class Shellout

  def self.relay src, dst
    while((buf = src.read(8192))); dst << buf; end 
  end 

  def self.execute(cmd)
    posix_spawn = POSIX::Spawn::Child.new(cmd)

    return posix_spawn.status, posix_spawn.out, posix_spawn.err
  end

  def run(cmd)
    Shellout::execute(cmd)
  end

end

if $0 == __FILE__
  shell = Shellout.new
  date = %q( ruby -e"  t = Time.now; STDOUT.puts t; STDERR.puts t  " )
  status, stdout, stderr = shell.run(date)
  p [status.exitstatus, stdout, stderr]

  sleep = %q( ruby -e"  p(sleep(1))  " )
  status, stdout, stderr = shell.run(sleep)
  p [status.exitstatus, stdout, stderr]

  cat = 'ruby -e"  puts Array.new(65536){ 42 }  "'
  status, stdout, stderr = shell.run(cat)
  p [status.exitstatus, stdout, stderr]

  status, stdout, stderr = shell.run('osiudfoisynajtet32')
  p [status.exitstatus, stdout, stderr]

end


Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
ohloh_scm-2.4.6 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.5 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.4 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.3 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.1 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.0 lib/ohloh_scm/shellout.rb
ohloh_scm-2.3.5 lib/ohloh_scm/shellout.rb
ohloh_scm-2.3.4 lib/ohloh_scm/shellout.rb
ohloh_scm-2.3.2 lib/ohloh_scm/shellout.rb
ohloh_scm-2.3.1 lib/ohloh_scm/shellout.rb
ohloh_scm-2.3.0 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.13 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.12 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.11 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.10 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.9 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.8 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.7 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.6 lib/ohloh_scm/shellout.rb
ohloh_scm-2.2.5 lib/ohloh_scm/shellout.rb