[chef] Re: How to run a shell command in a provider?


Chronological Thread 
  • From: Matthew Moretti < >
  • To: " " < >
  • Subject: [chef] Re: How to run a shell command in a provider?
  • Date: Wed, 8 Apr 2015 17:48:10 -0400

Hey Tayrone,

Take a look at the documentation for mixlib-shellout. You can inspect the .stdout of your command, and use that information.

mycommand = Mixlib::ShellOut.new("some-shell-command --flags")
mycommand.run_command
if mycommand.stdout =~ /running\.\.\./
  #do something
else
  #do something else
end

(pardon any syntax errors)

Matt Moretti


On Wed, Apr 8, 2015 at 3:51 PM, Tayrone Isa < " target="_blank"> > wrote:
Hi I am new to resource development, how can I do this in a provider,

Get output of a shell command, if output contains the word "running..."
set new_resource.status should be set to "running"

how can I do that ?




Archive powered by MHonArc 2.6.16.

§