Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
catalinnc
- Posts: 39
- Joined: 12 Jan 2015 11:56
#1
Post
by catalinnc » 04 Dec 2016 12:57
hi...
for now i use this to set a variable from a tool output...
Code: Select all
tool.exe some.file > result.txt
set /p _var=< result.txt
del result.txt
can this be done without the "middle man" result.txt?
meaning to pipe the tool.exe output into _var?
thanks...
_
-
jfl
- Posts: 226
- Joined: 26 Oct 2012 06:40
- Location: Saint Hilaire du Touvet, France
-
Contact:
#2
Post
by jfl » 04 Dec 2016 14:49
This should do it in simple cases:
Code: Select all
for /f "delims=" %%l in ('tool.exe some.file') do set _var=%%l
Note however that if your tool may output an empty line, or one line with just spaces, the above command will not capture it. A more complex code would be needed in this case.