开发者

Batch redirect output stderr to file and piped output stdout to file

I have a backup script that calls SVN dump, outputs stderr to a file then pipes the output to 7zip.

I now have to port this system to windows usi开发者_开发百科ng a batch file but I cannot seem to get access to the file twice in the one line like linux will let me, is there an alternative syntax?

svnadmin dump D:\Repo\example 2>> %logfile% | 7za a new.7z >> %logfile%

(above is just an example)

In windows if I try to do this I get an error that the file is already being accessed. How can I make sure I get error both from the svnadmin and also from the 7za to my logfile?


You can also use a block to redirect both to the logfile directly.

Redirecting the stdout with 1>>&2 to stderr and then combine both with the parenthesis and redirect it with a single 2>> to the logfile.

(svnadmin dump D:\Repo\example | 7za a new.7z 1>>&2 ) 2>> %logfile%


This does the trick for me:

( svnadmin dump D:\Repo\example 2>> %logfile% | 7za a new.7z >> %logfile%.tmp ) & copy %logfile%+%logfile%.tmp
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜