Reputation: 599
I am trying to call a command in batch file using "call" method and whatever is the output of that command, I want to write in a file. I went through from this link but cannot find the answer.
I am using this command
call %confPath% GetIniString %datFile% Keyname name >%newFile% >&1
but it creates a empty file always. How can i write the output of above command in the file?
Thanks in advance.
Upvotes: 0
Views: 160
Reputation: 2942
>%newFile%
redirects the standard output to a file. in >&1
, the 1
stands for standard output, and if no stream is specified, standard output is the default, so >&1
redirects on itself, although it was already redirected with the first command. So, this is illegal and shouldn't produce a file at all. In my tests, this just aborts with an errormessage.
The usual idiom 2>&1
, OTOH, redirects stream 2, which is standard ERROR, to standard output, which ensures that both output and error messages end up in the file.
Upvotes: 1