0

I have a bat file that calls chef-client (as well as other things). When I redirect the output of my batch file to a file, it doesn't print the output of chef-client, but I can't understand why.

For example, I have test.bat with only this line (I've simplified it to this to isolate the problem, but in reality has more)

call chef-client %*

This prints

Starting Chef Client, version 12.13.37

followed by rest of output

Doing this

test.bat > test.log 2>&1

prints nothing to test.log (it creates an empty file)

If I even take the contents of chef-client.bat and call it directly, I see the same results:

C:\opscode\chef\embedded\bin\ruby.exe C:\opscode\chef\bin\chef-client remoteapp::default > C:\test.log 2>&1

prints nothing to test.log

but removing the redirection prints

Starting Chef Client, version 12.13.37

as I would expect. How can I get redirection to file working here?

Jeff
  • 35,755
  • 15
  • 108
  • 220

1 Answers1

0

Some programs detect that standard input or output has been redirected to a file (not a terminal) and do something else (or nothing)

You have stumbled on such a program.

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219