相关疑难解决方法(0)

在批处理文件中读取stdin流

是否可以在批处理文件中使用管道stdin流?

我希望能够将一个命令的输出重定向到我的批处理文件process.bat列表中,这样:

C:\>someOtherProgram.exe | process.bat
Run Code Online (Sandbox Code Playgroud)

我的第一次尝试看起来像:

echo OFF
setlocal

:again
set /p inputLine=""
echo.%inputLine%
if not (%inputLine%)==() goto again

endlocal
:End
Run Code Online (Sandbox Code Playgroud)

当我用type testFile.txt | process.bat它测试时,它会反复打印出第一行.

还有另外一种方法吗?

windows stdin stdout batch-file

33
推荐指数
1
解决办法
3万
查看次数

标签 统计

batch-file ×1

stdin ×1

stdout ×1

windows ×1