btw - you are simply re-writing the open4 gem - why not use it?
Because I already kind of knew Open3 and it took me long enough to figure out how to use that one....and I like to make my life as difficult as possible.
So now I'm trying Open4 as you suggest and have a couple questions.
pid, stdin, stdout, stderr = Open4::popen4 "zmprov"
stdin.puts "sm shares"
puts stderr.read.strip if !stderr.read.strip.empty?
puts stdout.read.strip if stderr.read.strip.empty?
The check for stderr being empty? doesn't work...it prints a blank line if no error was returned so I tried checking for newline('\n') but it doesn't work either. What do I check for if nothing was returned on stderr?
The other thing I noticed is that I have to include the stdin.close or the program stops. I guess it's waiting for the close? It can't be after I try to print stderr/stdout either...it has to be before I check for those. So I guess I have to send all my input and then close the input and then check the statuses of stdout/stderr to decide how to proceed?
Looks like this will work and there doesn't seem to be any blocking getting in the way. Eventually I'm going to be sending thousands of these commands to the zmprov> prompt so I want this to be a tight and fast as possible. As long as I can get the full stdout/stdin of the last command before moving on to the next account...I think this will work.