【发布时间】:2022-01-08 00:22:14
【问题描述】:
是否可以在批处理文件中使用管道标准输入流?
我希望能够将一个命令的输出重定向到我的批处理文件process.bat 列表中,所以:
C:\>someOtherProgram.exe | process.bat
我的第一次尝试是这样的:
echo OFF
setlocal
:again
set /p inputLine=""
echo.%inputLine%
if not (%inputLine%)==() goto again
endlocal
:End
当我使用type testFile.txt | process.bat 对其进行测试时,它会重复打印出第一行。
还有其他方法吗?
【问题讨论】:
-
好问题,好答案,真的搞砸了,没有更好的答案!
标签: windows batch-file stdout stdin