【问题标题】:How to pass the output of a executable as one of args of another executable in Windows CMD?如何将可执行文件的输出作为 Windows CMD 中另一个可执行文件的参数之一传递?
【发布时间】:2013-02-23 03:06:12
【问题描述】:

作为标题,

我需要在我的程序中处理数据,

现有的可执行文件需要哪些数据。

我想通过管道传递数据,而不是将数据写入文件。

我的平台是 Windows 7。

谁能帮帮我?

谢谢!

【问题讨论】:

    标签: windows cmd pipe


    【解决方案1】:

    您不能使用管道将输出作为参数传递给另一个程序。管道将一个进程的 STDOUT 与另一个进程的 STDIN 连接起来。

    如果您希望将第一个进程的输出用作第二个进程的参数,您可以执行以下操作:

    @echo off
    
    setlocal EnableDelayedExpansion
    
    for /f "tokens=*" %%a in ('p1.exe') do set output=!output! %%a
    
    p2.exe "%output%" /foo /bar ...
    
    endlocal
    

    【讨论】:

      猜你喜欢
      • 2010-12-14
      • 1970-01-01
      • 2016-04-24
      • 2017-07-06
      • 2014-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-02
      相关资源
      最近更新 更多