English 中文(简体)
我怎么能够把指挥(在分批飞行)的产出转用于档案?
原标题:How can I redirect the output of a command (running in a batch loop) to a file?

I have a windows batch file, which iterates over files in a folder and runs a command on each file. Specifically I am running xmllint to validate some files:

for %%i in (c:	emp*.xml) do (
   C:XMLLINTxmllint -noout -schema "C:schemasschema.xsd" "%%~dpnxi" >> c:output.txt
)

它目前显示屏幕上的产出。 我想显示所有这些指挥部在产出档案中的产出。 我如何能够做到这一点? 通过使用配对操作员(>>)来,除创建空白档案外,没有完成任何工作。

这是否是因为食肉?

最佳回答

如果你试图从该方案中转呈错误产出,则可能写上斜体。 您可以尝试将其与:

for %%i in (c:	emp*.xml) do (
   C:XMLLINTxmllint -noout -schema "C:schemasschema.xsd" "%%~dpnxi" >> c:output.txt 2>&1
)

Basically the 2>&1 at the end means redirect anything from stderr (which is 2) to stdout (which is 1). Since stdout is redirected to a file, you should now see the stderr stream in the file. Hope this works for you!

问题回答

I ve never used it, but if its documentation is here, have you tried just removing your "-noout" option, or adding an: "-output c:output.txt"?





相关问题
How to use redirect_to to a non-Rails URL with query params?

We just had an existing use of redirect_to break due to a Rails upgrade, and it led to a question. I ve been experimenting, and I don t seem to find a way to use redirect_to to send the user to a non-...

Apache authentication: Redirect on failure, reliably?

I ve set my ErrorDocument 401 to point to my website s account creation page, but not all browsers seem to honor this redirect (Safari). Also, other browsers (Firefox, Chrome) never quit asking for ...

Response.Redirect HTTP status code

Why is it that ASP/ASP.NET Response.Redirect uses a HTTP-302 status code ("Moved Temporarily") even though in most cases a HTTP-301 status code ("Moved Permanently") would be more appropriate?

Exceptions: redirect or render?

I m trying to standardize the way I handle exceptions in my web application (homemade framework) but I m not certain of the "correct" way to handle various situations. I m wondering if there is a ...

Cakephp is not redirecting properly when pages are cached

I am having some issues with a site that was working correctly until i implemented full page caching in CakePHP. I have followed the guidance in the Manual and have my $session->flash in a no-cache ...

热门标签