Printing command output

Hi everyone,

Whats the easiest way to print command output while its running? I’ve found
older mailing list questions about this and things on SO but they mostly
point to setting chef logging to debug which is not what I want. I would
like to always print the output for this particular command as it often
takes awhile to run and has valuable information.

Bryan

On Friday, November 21, 2014 at 1:37 PM, Bryan Baugher wrote:

Hi everyone,

Whats the easiest way to print command output while its running? I've found older mailing list questions about this and things on SO but they mostly point to setting chef logging to debug which is not what I want. I would like to always print the output for this particular command as it often takes awhile to run and has valuable information.

Bryan
Setting the log level to info or debug is the only way currently: https://github.com/opscode/chef/blob/346aff0078a676d8c05319c017b891184426d004/lib/chef/provider/execute.rb#L55-L57

It wouldn’t be too difficult to write a patch to let you toggle that yourself, if you’re interested. It would also be pretty easy to write your own variant of the execute resource that always sets a live stream.

Daniel DeLeo

On Nov 21, 2014, at 2:51 PM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, November 21, 2014 at 1:37 PM, Bryan Baugher wrote:

Hi everyone,

Whats the easiest way to print command output while its running? I've found older mailing list questions about this and things on SO but they mostly point to setting chef logging to debug which is not what I want. I would like to always print the output for this particular command as it often takes awhile to run and has valuable information.

Bryan
Setting the log level to info or debug is the only way currently: https://github.com/opscode/chef/blob/346aff0078a676d8c05319c017b891184426d004/lib/chef/provider/execute.rb#L55-L57

It wouldn’t be too difficult to write a patch to let you toggle that yourself, if you’re interested. It would also be pretty easy to write your own variant of the execute resource that always sets a live stream.

You could use ruby_block resources before and after the execute to set/reset the log level I think.

--Noah

I sometimes use Tom Weiss’ technique from this thread so I’m not buried by debug output:

Thanks,
--Charles

Charles Johnson — Solutions Architect
(510) 545-9485 – charles@getchef.com – my: Linkedin Twitter

CHEF

TM
getchef.com Blog Facebook Twitter Youtube

On November 21, 2014 at 2:55:14 PM, Noah Kantrowitz (noah@coderanger.net) wrote:

On Nov 21, 2014, at 2:51 PM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, November 21, 2014 at 1:37 PM, Bryan Baugher wrote:

Hi everyone,

Whats the easiest way to print command output while its running? I've found older mailing list questions about this and things on SO but they mostly point to setting chef logging to debug which is not what I want. I would like to always print the output for this particular command as it often takes awhile to run and has valuable information.

Bryan
Setting the log level to info or debug is the only way currently: https://github.com/opscode/chef/blob/346aff0078a676d8c05319c017b891184426d004/lib/chef/provider/execute.rb#L55-L57

It wouldn’t be too difficult to write a patch to let you toggle that yourself, if you’re interested. It would also be pretty easy to write your own variant of the execute resource that always sets a live stream.

You could use ruby_block resources before and after the execute to set/reset the log level I think.

--Noah

Something like this might work? :
gist:7fee6a550f11efafc48e · GitHub .

Last I recall there was a slight awkwardness because chef doesn't flush the
"io" object; I wrote this a while ago. It has been working well enough for
me :slight_smile:

-Greg

On Sun, Nov 23, 2014 at 9:38 AM, Charles Johnson charles@opscode.com
wrote:

I sometimes use Tom Weiss’ technique from this thread so I’m not buried by
debug output:

stdout - How can I display the output of a Opscode Chef bash command in my console? - Stack Overflow

Thanks,
--Charles

Charles Johnson — Solutions Architect

(510) 545-9485 – http://mailto:charles@getchef.com/charles@getchef.com
charles@opscode.com – *my: *Linkedin
http://www.linkedin.com/pub/charles-johnson/1/b38/6a5 Twitter
https://twitter.com/chipadeedoodah

CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ http://www.getchef.com/blog/
Blog http://www.opscode.com/blog/ Facebook
https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/getchefdotcom Youtube
https://www.youtube.com/getchef

On November 21, 2014 at 2:55:14 PM, Noah Kantrowitz (noah@coderanger.net)
wrote:

On Nov 21, 2014, at 2:51 PM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, November 21, 2014 at 1:37 PM, Bryan Baugher wrote:

Hi everyone,

Whats the easiest way to print command output while its running? I've
found older mailing list questions about this and things on SO but they
mostly point to setting chef logging to debug which is not what I want. I
would like to always print the output for this particular command as it
often takes awhile to run and has valuable information.

Bryan
Setting the log level to info or debug is the only way currently:
https://github.com/opscode/chef/blob/346aff0078a676d8c05319c017b891184426d004/lib/chef/provider/execute.rb#L55-L57

It wouldn’t be too difficult to write a patch to let you toggle that
yourself, if you’re interested. It would also be pretty easy to write your
own variant of the execute resource that always sets a live stream.

You could use ruby_block resources before and after the execute to
set/reset the log level I think.

--Noah