Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 40,904 of 42,547    |
|    foxidrive to xanadu1215@gmail.com    |
|    Re: Batch Files - show output on screen     |
|    19 Feb 14 14:31:20    |
      From: foxidrive@server.invalid              On 19/02/2014 06:55, xanadu1215@gmail.com wrote:       > On Saturday, December 4, 2010 4:51:44 AM UTC-5, foxidrive wrote:       >> On 4/12/2010 20:25, techman41973 wrote:       >>> I know you can pipe the output of a batch file to a text file       >>> such as launch.bag> log_file.txt       >>> but this turns off the output on the screen.       >>> Is there a way to keep the output on the screen AND write the output       >>> to a text file?       >>       >> Use a TEE filter.       >>       >> --       >> Regards,       >> Mic       >       > T is a wonderful thing.       > And I wish we were a UNIX world again but       > I use Tail.       > I output the batch to a file batch > file.txt       > Then run tail on the file.       > Easy Peasy.       > Steph :D       >              This batch TEE filter was written by Dave Benham                             ::batchTee.bat OutputFile [+]        ::        :: Write each line of stdin to both stdout and outputFile.        :: The default behavior is to overwrite any existing outputFile.        :: If the 2nd argument is + then the content is appended to any existing        :: outputFile.        ::        :: Limitations:        ::        :: 1) Lines are limited to ~1000 bytes. The exact maximum line length       varies        :: depending on the line number. The SET /P command is limited to       reading        :: 1021 bytes per line, and each line is prefixed with the line number       when        :: it is read.        ::        :: 2) Trailing control characters are stripped from each line.        ::        :: 3) Lines will not appear on the console until a newline is issued, or        :: when the input is exhaused. This can be a problem if the left side of        :: the pipe issues a prompt and then waits for user input on the same       line.        :: The prompt will not appear until after the input is provided.        ::        :: 4) Attempting to abort the piped commands will lock up the console.       Ouch!        ::               @echo off        if "%~1" equ ":tee" goto :tee               setlocal disableDelayedExpansion        :lock        set "teeTemp=%temp%\tee%time::=_%"        2>nul (        9>"%teeTemp%.lock" (        (find /n /v ""&echo END) >"%teeTemp%.tmp" | <"%teeTemp%.tmp" "%~f0"       :tee %*        (call )        ) || goto :lock        )        del "%teeTemp%.lock" "%teeTemp%.tmp"        exit /b               :tee        setlocal enableDelayedExpansion        set "redirect=>"        if "%~3" equ "+" set "redirect=>>"        8%redirect% %2 (        for /l %%. in () do (        set "ln="        set /p "ln="        if defined ln (        if "!ln:~0,3!" equ "END" exit        set "ln=!ln:*]=!"        (echo(!ln!)        (echo(!ln!)>&8        )        )        )              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca