I'm trying this approach, but it seems to wait for user input (and then doesn't see the whole command):
ruby_block "first-search" do
block do
puts "the service WZCSV was found"
end
action :create
only_if "sc query WZCSVC \| find /C /I \"running\""
end
Is there something wrong with how I've phrased the "only_if portion of this ruby block?
It halts there and when I hit enter, it's as if something was not sent to the "sc" command:
[Mon, 24 Oct 2011 10:58:18 -0400] DEBUG: Executing sc query WZCSVC | find /C /I "running"
[Mon, 24 Oct 2011 11:00:18 -0400] DEBUG: ---- Begin output of sc query WZCSVC | find /C /I "running" ----
[Mon, 24 Oct 2011 11:00:18 -0400] DEBUG: STDOUT:
ERROR: Invalid Option
....
[Mon, 24 Oct 2011 11:00:18 -0400] DEBUG: STDERR:
[Mon, 24 Oct 2011 11:00:18 -0400] DEBUG: ---- End output of sc query WZCSVC | find /C /I "running" ----
[Mon, 24 Oct 2011 11:00:18 -0400] DEBUG: Ran sc query WZCSVC | find /C /I "running" returned 0
the service WZCSV was found
[Mon, 24 Oct 2011 11:00:18 -0400] INFO: ruby_block[first-search] called
But that all looks healthy - any suggestions?
On Thu, Oct 20, 2011 at 2:48 PM, Maven User < " target="_blank"> > wrote:Hello again all -
First - thanks all for all the really helpful replies to any/all earlier posts. I've been able to move pretty quickly because of the help.
Now I have a tougher question.
I'm trying to work with a windows service for an item that we build and install.
This means stopping it if it exists, installing it if it doesn't and then starting it if it isn't already running.
I've tried to make the only_if/not_if be a "sc query <servicename>", but I'm seeing mixed results in different windows servers.
On Windows 7, if the service doesn't exist, I get a non-zero (1060) return value, on Windows server 2003 (R2), I get 0 regardless if the service exists or doesn't exist.
I've been thinking about just parsing the output of the "sc query" command versus just relying on the return value, but this is starting to feel kludgy.
Any suggestions?
Archive powered by MHonArc 2.6.16.