|
MYS
元老会员
        
积分 5170
发帖 1637
注册 2002-10-16 来自 广东佛山
状态 离线
|
『楼 主』:
转贴:DOS命令淘金——ECHO命令的使用
使用 LLM 解释/回答一下
DOS命令淘金——ECHO命令的使用
ECHO命令是大家都熟悉的DOS批处理命令的一条子命令,但它的一些功能和用法也许你并不是全都知道,不信你瞧:
1. 作为控制批处理命令在执行时是否显示命令行自身的开关
格式:ECHO
如果想关闭“ECHO OFF”命令行自身的显示,则需要在该命令行前加上“@”。
2. 显示当前ECHO设置状态
格式:ECHO
3. 输出提示信息
格式:ECHO信息内容
上述是ECHO命令常见的三种用法,也是大家熟悉和会用的,但作为DOS命令淘金者你还应该知道下面的技巧:
4. 关闭DOS命令提示符
在DOS提示符状态下键入ECHO OFF,能够关闭DOS提示符的显示使屏幕只留下光标,直至键入ECHO ON,提示符才会重新出现。
5. 输出空行,即相当于输入一个回车
格式:ECHO.
值得注意的是命令行中的“.”要紧跟在ECHO后面中间不能有空格,否则“.”将被当作提示信息输出到屏幕。另外“.”可以用,:;”/+等任一符号替代。
在下面的例子中ECHO.输出的回车,经DOS管道转向作为TIME命令的输入,即相当于在TIME命令执行后给出一个回车。所以执行时系统会在显示当前时间后,自动返回到DOS提示符状态:
C:>ECHO.|TIME
ECHO命令输出空行的另一个应用实例是:将ECHO.加在自动批处理文件中,使原本在屏幕下方显示的提示画面,出现在屏幕上方。
6. 答复命令中的提问
格式:ECHO答复语|命令文件名
上述格式可以用于简化一些需要人机对话的命令(如:CHKDSK/F;FORMAT Drive:;del *.*)的操作,它是通过DOS管道命令把ECHO命令输出的预置答复语作为人机对话命令的输入。下面的例子就相当于在调用的命令出现人机对话时输入“Y”回车:
C:>ECHO Y|CHKDSK/F
C:>ECHO Y|DEL A :*.*
7. 建立新文件或增加文件内容
格式:ECHO 文件内容>文件名
ECHO 文件内容>>文件名
例如:C:>ECHO @ECHO OFF>AUTOEXEC.BAT建立自动批处理文件
C:>ECHO C:\CPAV\BOOTSAFE>>AUTOEXEC.BAT向自动批处理文件中追加内容
C:TYPE AUTOEXEC.BAT显示该自动批处理文件
@ECHO OFF
C:\CPAV\BOOTSAFE
8. 向打印机输出打印内容或打印控制码
格式:ECHO 打印机控制码>PRN
ECHO 打印内容>PRN
下面的例子是向M-1724打印机输入打印控制码。<Alt>156是按住Alt键在小键盘键入156,类似情况依此类推:
C:>ECHO +156+42+116>PRN(输入下划线命令FS*t)
C:>ECHO +155@>PRN(输入初始化命令ESC@)
C:>ECHO.>PRN(换行)
9. 使喇叭鸣响
C:>ECHO ^G
“^G”是用Ctrl+G或Alt+007输入,输入多个^G可以产生多声鸣响。使用方法是直接将其加入批处理文件中或做成批处理文件调用。
10.执行ESC控制序列修改屏幕和键盘设置
我们知道DOS的设备驱动程序ANSI.SYS提供了一套用来修改屏幕和键盘设置的ESC控制序列。如执行下述内容的批处理程序可以把功能键F12定义为DOS命令“DIR/W”,并把屏幕颜色修改为白色字符蓝色背景。
@ECHO”←
Gold Panning for DOS Commands - Usage of the ECHO Command
The ECHO command is a sub-command of the well-known DOS batch processing command, but some of its functions and usages may not all be known to you. Just take a look:
1. As a switch to control whether the command line itself is displayed when the batch processing command is executed
Format: ECHO
If you want to turn off the display of the "ECHO OFF" command line itself, you need to add "@" in front of the command line.
2. Display the current ECHO setting status
Format: ECHO
3. Output a prompt message
Format: ECHO message content
The above are the three common usages of the ECHO command, which are also familiar and used by everyone. But as a gold digger of DOS commands, you should also know the following skills:
4. Turn off the DOS command prompt
Typing ECHO OFF at the DOS prompt can turn off the display of the DOS prompt, leaving only the cursor on the screen. The prompt will reappear until ECHO ON is typed.
5. Output an empty line, which is equivalent to entering a carriage return
Format: ECHO.
It is worth noting that the "." in the command line should be immediately after ECHO without a space in between, otherwise the "." will be output to the screen as a prompt message. Also, the "." can be replaced by any one of the symbols such as,, : ; " / +, etc.
In the following example, the carriage return output by ECHO. is redirected through the DOS pipeline as the input of the TIME command, which is equivalent to giving a carriage return after the TIME command is executed. So when executed, the system will automatically return to the DOS prompt state after displaying the current time:
C:>ECHO.|TIME
Another application example of the ECHO command outputting an empty line is: adding ECHO. in the autoexec batch file to make the originally displayed prompt screen at the bottom of the screen appear at the top of the screen.
6. Answer the question in the command
Format: ECHO answer | command file name
The above format can be used to simplify the operation of some commands that require man-machine dialogue (such as CHKDSK/F; FORMAT Drive:; del *.*). It is through the DOS pipeline command that the preset answer output by the ECHO command is used as the input of the man-machine dialogue command. The following example is equivalent to entering "Y" and pressing Enter when the called command has a man-machine dialogue:
C:>ECHO Y|CHKDSK/F
C:>ECHO Y|DEL A :*.*
7. Create a new file or add content to a file
Format: ECHO file content > file name
ECHO file content >> file name
For example: C:>ECHO @ECHO OFF>AUTOEXEC.BAT to create an autoexec batch file
C:>ECHO C:\CPAV\BOOTSAFE>>AUTOEXEC.BAT to append content to the autoexec batch file
C:TYPE AUTOEXEC.BAT to display the autoexec batch file
@ECHO OFF
C:\CPAV\BOOTSAFE
8. Output print content or print control codes to the printer
Format: ECHO printer control code > PRN
ECHO print content > PRN
The following example is to input print control codes to the M-1724 printer. <Alt>156 is to hold down the Alt key and type 156 on the numeric keypad. Similar situations are类推:
C:>ECHO +156+42+116>PRN (input the underline command FS*t)
C:>ECHO +155@>PRN (input the initialization command ESC@)
C:>ECHO.>PRN (new line)
9. Make the speaker beep
C:>ECHO ^G
"^G" is input with Ctrl+G or Alt+007. Entering multiple ^G can produce multiple beeps. The usage is to directly add it to the batch file or make a batch file call.
10. Execute ESC control sequences to modify screen and keyboard settings
We know that the device driver ANSI.SYS of DOS provides a set of ESC control sequences for modifying screen and keyboard settings. For example, executing a batch program with the following content can define the function key F12 as the DOS command "DIR/W" and modify the screen color to white characters on a blue background.
@ECHO"←
|

我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
|
|
2002-10-25 00:00 |
|
|
hit
初级用户
  孤胆枪手
积分 688
发帖 148
注册 2002-10-26 来自 陕西
状态 离线
|
|
2002-10-26 00:00 |
|
|
中华dos
初级用户
 
积分 107
发帖 3
注册 2002-10-26
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
好,怎么琢磨出来的?佩服。
Well, how did you figure it out? Impressive.
|
|
2002-10-26 00:00 |
|
|
kickout
高级用户
   
积分 667
发帖 135
注册 2002-10-25
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
good.加油啊!
|

================================= kickout
大功告成,打个Kiss!
|
|
2002-10-26 00:00 |
|
|
无妄★模拟
初级用户
  蝎蛇统领
积分 280
发帖 35
注册 2003-5-21
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
真高啊!你怎么发现的啊?
That's really high! How did you find it?
|

我是菜鸟,我要变成老鸟!
www.10.164.63.101.com |
|
2003-5-27 00:00 |
|
|
pc1415926
初级用户
 
积分 167
发帖 24
注册 2003-6-7
状态 离线
|
|
2003-6-8 00:00 |
|
|
mgc8915
中级用户
  
积分 386
发帖 48
注册 2003-6-29
状态 离线
|
|
2003-8-20 00:00 |
|
|
iceboy
银牌会员
    
积分 1681
发帖 512
注册 2003-8-2
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
@ECHO”←
好像不行啊,在 VMWare 里试了
@ECHO”←
It doesn't seem to work, tried it in VMWare
|

Somehow somewhere I've got to choose.
No matter if it is win or lose. |
|
2003-8-20 00:00 |
|
|
DOCO
初级用户
 
积分 133
发帖 6
注册 2003-9-26
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
不行
我是在WIN98下
来玩DOS
的
No problem. I'm playing DOS under WIN98.
|
|
2003-9-26 00:00 |
|