0

I have a .bat script for a deployment task. I it is needed to run with some parameters for the correct work, smthg like this:

script.bat -x=param1 -b=param2 -c=param3 ( this is how it looks in cmd on windows )

How do I correctly specify the cookbook to run a such script? I seen this done for a .sh but no .bat (yes, I need it to be a .bat not cmd or ps1) If it isn't hard, give an example. Thx

SilliS
  • 175
  • 2
  • 11

1 Answers1

3

I would use a batch ressource like this

batch "run-script" do
  command "script.bat -x=param1 -b=param2 -c=param3"
  cwd "Path where the script is"
  action :nothing
end

And use a notification from the deployment ressource you use

notifies :run, "bash[run-script]", :immediately

If the deployment ressource is correctly idempotent your script would run only if the deploy succeed.

FWIW a .bat or a .cmd are roughtly the same thing, see Windows batch files: .bat vs .cmd?

Community
  • 1
  • 1
Tensibai
  • 15,080
  • 1
  • 35
  • 53
  • Do I need to set the full path to the bat in the cookbook? because when i do this way it does do anything – SilliS Aug 20 '14 at 09:09
  • If it is not in the path yes, you may set the directory to where execute the ressource inside the ressource with cwd attribute. I edited my answer to include it – Tensibai Aug 20 '14 at 09:52