开发者

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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜