Page 1 of 1
output on display and log file
Posted: 18 Jun 2013 07:14
by krunoo
Hello,
is there a why to see output on screen and put logfile in txt file at the same time?
I have something like this:
for /f "tokens=1,2 delims= " %%a in (1.txt) do SOMETHING >> logfile.txt
...
...
...
for /f "tokens=1,2 delims= " %%a in (2.txt) do SOMETHING >> logfile2.txt
I dont want to use pause.
thx,
Kruno
Re: output on display and log file
Posted: 18 Jun 2013 09:13
by Endoro
Re: output on display and log file
Posted: 18 Jun 2013 11:23
by aGerman
I wrote it this way:
TEE.bat
Code: Select all
@echo off &setlocal EnableExtensions DisableDelayedExpansion
set "line=" &set "file=%~1"
if not defined file goto :eof
set "_me_=%0"
setlocal EnableDelayedExpansion
echo(!cmdcmdline!|findstr "\"/c\" !_me_!" >nul ||goto :eof
endlocal
for /f delims^=^ eol^= %%i in ('"more|findstr /n ^^"') do (
setlocal EnableDelayedExpansion
if defined line (
echo(!line:*:=!
>>"!file!" echo(!line:*:=!
)
endlocal
set "line=%%i"
)
You could use it as follows:
That's not foolproof but it's suitable to satisfy my needs.
Regards
aGerman
Re: output on display and log file
Posted: 19 Jun 2013 00:17
by krunoo
Thank you Endoro and aGerman very much.
I test with TEE.bat and work very very nice...
You make my very hot day very pleasant.
Re: output on display and log file
Posted: 19 Jun 2013 06:34
by Aacini
An equivalent but simpler solution, is this:
Code: Select all
your command here > out.txt & type out.txt