Read file output into a variable
I have the output of a file that I would like t开发者_StackOverflow中文版o make a varabile in a batch program. How do I go about doing this? I would like to take the output of this, php file.php
and put it into a variable named %this%
. How do I do that?
[edit] Removed tags, this question is meant to provide an example for batch variable handling only. The fact that I used PHP was just an example, it could just as well be a python file that I'm reading the output from, or a regular executable.
@ECHO OFF
php file.php > output.txt
set /p OUTPUT= < output.txt
del output.txt
echo %OUTPUT%
for /f "delims=" %%x in ('php file.php') do set "this=%%x"
精彩评论