China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-02 21:15
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to display the execution result on the screen and also save the result to View 4,996 Replies 26
Original Poster Posted 2006-06-27 22:28 ·  中国 广东 珠海 电信
初级用户
Credits 112
Posts 40
Joined 2006-06-23 19:52
20-year member
UID 57473
Gender Male
Status Offline
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.
Floor 2 Posted 2006-06-28 10:51 ·  加拿大 Bell
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 3 Posted 2006-06-28 12:47 ·  中国 广东 珠海 电信
初级用户
Credits 112
Posts 40
Joined 2006-06-23 19:52
20-year member
UID 57473
Gender Male
Status Offline
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?
Floor 4 Posted 2006-06-28 13:33 ·  加拿大 Bell
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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:
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lhaboy085 +1 2009-06-22 13:34
Attachments
TEE.EXE (62.5 KiB, Credits to download 1 pts, Downloads: 156)
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 5 Posted 2006-06-28 13:56 ·  中国 北京 联通
初级用户
Credits 120
Posts 32
Joined 2006-06-19 16:31
20-year member
UID 57256
Status Offline
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?
Floor 6 Posted 2006-06-28 14:01 ·  加拿大 Bell
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
MKDIR "..\backup">>%DATE%.log

Should be changed to:

MKDIR "..\backup" 2>>%DATE%.log
or
MD "..\backup" 2>>%DATE%.log
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 7 Posted 2006-06-28 14:01 ·  中国 上海 虹口区 电信
高级用户
★★
Credits 653
Posts 252
Joined 2006-04-16 19:48
20-year member
UID 53939
Status Offline
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
Floor 8 Posted 2006-06-28 14:06 ·  中国 四川 成都 联通
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
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 ]

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 9 Posted 2006-06-28 19:36 ·  中国 广东 珠海 电信
初级用户
Credits 112
Posts 40
Joined 2006-06-23 19:52
20-year member
UID 57473
Gender Male
Status Offline
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.
Floor 10 Posted 2006-06-29 01:21 ·  加拿大 Bell
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 11 Posted 2006-06-29 01:24 ·  加拿大 Bell
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 12 Posted 2006-06-29 18:54 ·  中国 广东 珠海 电信
初级用户
Credits 112
Posts 40
Joined 2006-06-23 19:52
20-year member
UID 57473
Gender Male
Status Offline
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
Floor 13 Posted 2006-06-30 01:46 ·  加拿大 Bell
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
I myself tried the above command, but didn't find any new window popping up showing a line of garbled code.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 14 Posted 2006-07-02 16:24 ·  中国 广东 珠海 电信
初级用户
Credits 112
Posts 40
Joined 2006-06-23 19:52
20-year member
UID 57473
Gender Male
Status Offline
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?
Floor 15 Posted 2006-07-03 09:46 ·  加拿大 Bell
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
The command "chcp 936" can switch the current display code page to Simplified Chinese.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Forum Jump: