Computer Hope
Microsoft => Microsoft DOS => Topic started by: srujana on November 29, 2011, 09:15:26 AM
-
I want to display the output both on screen and log.txt file
like
echo %%a > log.txt
this is redirecting to txt file. i want on screen as well
is ther any way?
-
The only way I know of is to echo the line twice.
echo %%A > log.txt
echo %%A
I know it is an extra line, but is there any reason this won't work?
-
Unlike most Nix systems there is not a native way to do this in batch. You can use the TEE command on most NIX operating systems to do this. I believe there is a Win32 port of it if you really want to do this.
-
Unlike most Nix systems there is not a native way to do this in batch. You can use the TEE command on most NIX operating systems to do this. I believe there is a Win32 port of it if you really want to do this.
There are plenty of Tee.exe programs around, not to mention any number of Tee.bat. Tee.cmd and Tee.vbs scripts. The most cursory of Google searches will turn up plenty of results, which it would be both tedious and redundant to reproduce here. In particular searching the Google archive of alt.msdos.batch.nt using intelligently chosen search terms is a fruitful method of finding solutions.
If the OP is using a business or school system where installation of third party executables is not allowed, then a cmd or vbs approach may be the only way.
-
You can use:
echo %%a >> log.txt
echo %%a
in one line, maybe use a pipe, fork, or do:
echo %%a >> log.txt && echo %%a
Thats your best option