# \[cucumber\] Where does STDOUT go?

**URL:** <https://www.ruby-forum.com/t/cucumber-where-does-stdout-go/166620>\
**Category:** RSpec\
**Created:** [April 27, 2009, 10:53pm UTC](https://www.ruby-forum.com/t/cucumber-where-does-stdout-go/166620 "2009-04-27T22:53:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 27, 2009, 10:53pm UTC](https://www.ruby-forum.com/t/cucumber-where-does-stdout-go/166620/1 "2009-04-27T22:53:14Z")

</div>

If one invokes a Ruby script from a cucumber step definition and that  
script contains “puts” statements then where does the output go? I have  
a script that when run from the command line displays “puts” output in  
the terminal session, but when run from a cucumber step definition  
produces no console output. It does however produce the expected output  
file in either case.

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 27, 2009, 11:27pm UTC](https://www.ruby-forum.com/t/cucumber-where-does-stdout-go/166620/2 "2009-04-27T23:27:54Z")

</div>

James B. wrote:

> If one invokes a Ruby script from a cucumber step definition and that  
> script contains “puts” statements then where does the output go? I have  
> a script that when run from the command line displays “puts” output in  
> the terminal session, but when run from a cucumber step definition  
> produces no console output. It does however produce the expected output  
> file in either case.

If you are running the command with the backticks it is simply being  
returned to that call. If you want to see that ouput you could add a  
puts.. for example:

puts `some_command`

If you are testing a CLI tool you may want to look how Cucumber’s and  
RSpec’s features capture and use the STDOUT and STDERR.

[http://github.com/aslakhellesoy/cucumber/blob/0e9f6066bbed0e0b73f4af0a18f186a7e13fea46/features/support/env.rb](http://github.com/aslakhellesoy/cucumber/blob/0e9f6066bbed0e0b73f4af0a18f186a7e13fea46/features/support/env.rb)

-Ben

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 28, 2009, 2:22am UTC](https://www.ruby-forum.com/t/cucumber-where-does-stdout-go/166620/3 "2009-04-28T02:22:52Z")

</div>

Ben M. wrote:

> If you are running the command with the backticks it is simply being  
> returned to that call. If you want to see that ouput you could add a  
> puts.. for example:
> 
> puts `some_command`

Thanks

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 28, 2009, 4:17am UTC](https://www.ruby-forum.com/t/cucumber-where-does-stdout-go/166620/4 "2009-04-28T04:17:46Z")

</div>

It produces console output for me.

Julian.
