I am trying to execute a shell script inside ruby code and return the result. I
am using Open3
for this.
Here is the code:
#!/usr/bin/env ruby
require 'rubygems'
require 'uri'
require 'net/http'
require 'open3' # require 'open3' in 1.9
AppArgs = Array.new
def get()
source = Net::HTTP.get('integration.twosmiles.com', '/status')
_shellScript = "grep 'commit' status.html"
fileHtml = File.new("status.html", "w+")
fileHtml.puts source
Open3.popen3(_shellScript) do |stdin, stdout, stderr|
puts stdout
puts stdin
puts stderr
end
end
get()
But it prints
#<IO:0x00000000a41ca8>
#<IO:0x00000000a41cf8>
#<IO:0x00000000a41c30>
I want to get the stings I searched in the stdout
. How to achieve this?