Sha256: 5e79a4b1fa5d6cdf105a5395622f038b8a18ba3817d60942db31f5a5137731cf

Contents?: true

Size: 920 Bytes

Versions: 9

Compression:

Stored size: 920 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

9 entries across 9 versions & 1 rubygems

Version Path
ohloh_scm-2.5.1 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.14 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.13 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.12 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.11 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.10 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.9 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.8 lib/ohloh_scm/shellout.rb
ohloh_scm-2.4.7 lib/ohloh_scm/shellout.rb