Reputation: 79
For example in this simple cookbook recipe:
batch "Clear_OS_Agent" do
code <<-EOH
@echo on
dir C:\
@echo off
EOH
action :run
When I run chef-client.bat
on a Windows node, I can get the result of dir C:\
But when I redirect in into a file chef-client.bat > C:\chef_log.txt
, there are only the general chef-client.bat
output over there, without the result of dir C:\
.
Upvotes: 0
Views: 999
Reputation: 6227
Do the redirect inside your recipe, not when you run chef-client like:
code <<-EOH
@echo on
dir C:\ > C:\chef_log.txt
@echo off
EOH
You can probably see the results of your run how you were doing it originally if you crank up the debug as well like:
chef-client.bat -l debug > C:\chef_log.txt
Edit:
If you have multiple commands you want redirected to the same log file you can do the following so you don't have to explicitly redirect each line:
(
echo one
echo two
echo three
dir C:\
) > C:\test.txt
Upvotes: 1