1

So my problem is that I need to have the output of running the command dumped to the screen and also capture it in a variable in a ruby script. I know that I can do the second part like this:

some_variable = `./some_kickbutt`

But my problem is that I need it to still print to the console as Hudson captures that output and records it for posterity's sake.

thanks in advance for any ideas...

2
  • why the heck would you give a -1 and NOT explain your reason. Plus, yes, I did find this question asked a bunch, but with no answers that applied to the correct question. Commented Jun 6, 2011 at 12:07
  • WOW! someone voted to close it based on it being geographically too localized! Is it because of "Hudson" mentioned up there? That cracks me up... Commented Jun 6, 2011 at 12:32

1 Answer 1

5

Just tee the stdout stream to stderr like so:

ruby -e 'var = `ls | tee /dev/stderr`; puts "\nFROM RUBY\n\n"; puts var' | nl

ruby -e 'var = `ls | tee /dev/stderr`; puts "\nFROM RUBY\n\n"; puts var' 2>&1 | nl
Sign up to request clarification or add additional context in comments.

1 Comment

After trying this is exactly what I needed. I've give you two green checkmarks if I could :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.