中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-15 09:09
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to display the execution result on the screen and also save the result to
Printable Version  5,490 / 26
Floor1 zhaxi Posted 2006-06-27 22:28
初级用户 Posts 40 Credits 112
The meaning of this title is that, for example, when the xcopy command is executed, many execution results will be displayed on the screen:

---------------------------------------
\\192.168.1.1\update\1.txt
\\192.168.1.1\update\2.txt
\\192.168.1.1\update\3.txt
3 files copied
---------------------------------------

If I need to save this command result to d:\a.txt, so I used xcopy ....>d:\a.txt, but the result is that the above execution results will not be displayed on the screen. Although now I can add a line at the end type d:\a.txt to output the just result on the screen, but it has a lag effect. And it is not the same as before that every time xcopy a file will dynamically display the execution result on the screen.

Now I want to ask if there is a statement that can not affect the display result on the screen and at the same time save the result to a file.
Floor2 Wengier Posted 2006-06-28 10:51
系统支持 Posts 10,521 Credits 27,736
This can be done through tools that provide this function, such as TEE. For example, use the following syntax:

XCOPY .... | TEE D:\A.TXT

This not only does not affect the display of the result on the screen, but also can save the result to one (or more) files.
Floor3 zhaxi Posted 2006-06-28 12:47
初级用户 Posts 40 Credits 112
Function description: Read data from standard input and output its content to a file.
Syntax: tee [-ai][--help][--version][file...]
Supplementary instructions: The tee command reads data from the standard input device, outputs its content to the standard output device, and saves it as a file at the same time. We can use tee to save the data imported by the pipeline into a file, and even save several files at one time.
Parameters: -a Append to the end of the existing file instead of overwriting it. If the file name given to the tee command already exists, it will overwrite the content of the file by default. With this parameter, the data will be added to the end of the file content instead of deleting the original content.
       -i Ignore interrupt signals
       --help Online help
       --version Display version information
Examples:
List the content of the text file slayers.story, and copy 3 copies at the same time, with the file names ss-copy1, ss-copy2, ss-copy3 respectively:
$ cat slayers.story |tee ss-copy1 ss-copy2 ss-copy3

-----------------------------------------------------------------------------------------

Unfortunately, I just can't download this software. I don't know which category it is in on DOS Home. Can you tell me the download address?
Floor4 Wengier Posted 2006-06-28 13:33
系统支持 Posts 10,521 Credits 27,736
Originally posted by zhaxi at 2006-6-28 12:47 PM:
Function description: Read data from standard input and output its content to a file.
  Syntax: tee
  Supplementary instructions: The tee command will read from the standard input device...


There are no such software in those websites. The DOS version of TEE is in the attachment:

Attachments
TEE.EXE (62.5 KiB)
Floor5 qdcr Posted 2006-06-28 13:56
初级用户 Posts 32 Credits 120
The same question:

@echo off
MKDIR "..\backup">>%DATE%.log
pause

If the back folder exists, in the dos console window it will display
A subdirectory or file ..\backup already exists.
And the content in %date%.log is empty.
Why is the redirection to the log file not working?
Floor6 Wengier Posted 2006-06-28 14:01
系统支持 Posts 10,521 Credits 27,736
MKDIR "..\backup">>%DATE%.log

Should be changed to:

MKDIR "..\backup" 2>>%DATE%.log
or
MD "..\backup" 2>>%DATE%.log
Floor7 asbai Posted 2006-06-28 14:01
高级用户 Posts 252 Credits 653
Originally posted by qdcr at 2006-6-28 13:56:
Ask the same question:
@echo off
MKDIR "..\backup">>%DATE%.log
pause

If the back folder exists, it will display in the dos console window
A subdirectory or file ..\backup already exis ...


>> Only redirect standard output, not error output. To redirect error output at the same time, use:

MKDIR "..\backup">>%DATE%.log 2>&1
Floor8 electronixtar Posted 2006-06-28 14:06
铂金会员 Posts 2,672 Credits 7,493
Why use this?

xcopy ........ 1>con 1>D:\a.txt

Or

xcopy ....... 1>con 1>D:\a.txt 1<&2

Why not?

Can we copy the data of handle 1 to handle 4, then 1 to the screen, and 4 to the file?

Or, use the mode command? It feels not very cool to use third-party tools

[ Last edited by electronixtar on 2006-6-28 at 14:24 ]
Floor9 zhaxi Posted 2006-06-28 19:36
初级用户 Posts 40 Credits 112
Originally posted by Wengier at 2006-6-28 13:33:

There is no such software in those websites. The DOS version of TEE is attached:



Thanks, Wengier. I've copied it down. I'll use it right away.

Also, can anyone help me upload choice.exe? Hehe. I'm using it under XP now. I don't know how to install DOS yet. I've been writing batch scripts under XP for several months.
Floor10 Wengier Posted 2006-06-29 01:21
系统支持 Posts 10,521 Credits 27,736
Originally posted by electronixtar at 2006-6-28 02:06 PM:
Why use this

xcopy ........ 1>con 1>D:\a.txt

Or

xcopy ....... 1>con 1>D:\a.txt 1<&2

It doesn't work?

Can you copy the data of handle 1 to handle 4, then 1 to the screen, and 4 to the file?

Or, use the mode command? It feels not very cool to use third-party tools


These of course don't work. If you really want to achieve it without using third-party tools, it's better to do it like this:
xcopy ....... >a.txt | type a.txt
Floor11 Wengier Posted 2006-06-29 01:24
系统支持 Posts 10,521 Credits 27,736
Originally posted by zhaxi at 2006-6-20 07:36 PM:

Thank you Wengier. I have copied it down. Use it immediately.

Also who can help me to put choice.exe also pass on, he he. I am now under XP to use. Also will not install dos. For a few months...

The choice command is basically only use in the pure DOS to compare useful, under XP use set /p to replace.
Floor12 zhaxi Posted 2006-06-29 18:54
初级用户 Posts 40 Credits 112
Why does a new window pop up when I use tee in the cmd of xp, showing a line of garbled code and then closing? I guess this line of garbled code must be "1 file(s) copied". What do I need to install to remove the garbled code?

COPY d:\dos\end.txt d:\ | TEE D:\A.TXT
Floor13 Wengier Posted 2006-06-30 01:46
系统支持 Posts 10,521 Credits 27,736
I myself tried the above command, but didn't find any new window popping up showing a line of garbled code.
Floor14 zhaxi Posted 2006-07-02 16:24
初级用户 Posts 40 Credits 112
Hey. I ran Tee under the cmd in XP and it seems that Chinese names are not supported. When encountering paths with Chinese names, it shows as ???. What should I do about this?
Floor15 Wengier Posted 2006-07-03 09:46
系统支持 Posts 10,521 Credits 27,736
The command "chcp 936" can switch the current display code page to Simplified Chinese.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023