RockPaperScissors

LizardSpock

Ruby Run (Execute) Command Line

| Comments

Also a gist on github. This code snippet is an example of how to execute a command line argument in ruby and display the output

#!/usr/bin/env ruby
do_and_report("ls")

#Small function to run a command and output return values
def do_and_report(command)
   f = open("| #{command}")
   g = Array.new
   while (foo = f.gets)
      g << foo
   end
   g.each do |element|
      puts element
   end
end

Comments