Advertisement
Guest User

open3 Ruby

a guest
Apr 27th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.33 KB | None | 0 0
  1. require 'open3'
  2.  
  3. out = ""
  4. Open3.popen2e("ping www.google.com") do |stdin, stdout_err, wait_thr|
  5.   while !stdout_err.eof? && (next_line = stdout_err.readline) do
  6.     puts out
  7.     out << next_line
  8.   end
  9.   if wait_thr.value.success?
  10.     puts "SUCCESS: #{wait_thr.value}"
  11.   else
  12.     puts "FAILED: #{wait_thr.value}"
  13.   end
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement