Note. All this requires that the commands are in a batch file. Therefore, double signs % .
You can use the for command to capture the output of the command:
for /f "usebackq delims=" %%x in (`ScriptB`) do set args=%%x
then you can use this output in another command:
AnotherScript %args%
This will cause %args% to contain the last line from the output of ScriptB . If it returns only one row, you can flip it into one row:
for /f "usebackq delims=" %%x in (`ScriptB`) do AnotherScript %%x
When used outside of a batch file, you should use %x instead of %%x .
However, if ScriptB returns more than one line, AnotherScript is executed for each of these lines. You can get around this, although only in a batch file, by splitting it after the first iteration of the loop:
for /f "usebackq delims=" %%x in (`ScriptB`) do AnotherScript %%x & goto :eof
Joey source share