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-01 06:15
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Ask about reading the content of a txt file into a variable under pure DOS View 5,468 Replies 19
Floor 16 Posted 2006-09-01 17:14 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
### 首先看第一部分:

#### 关于 `namepass.txt` 文件内容
`namepass.txt` 文件里有两行内容,分别是 `username` 和 `password`,应该是用来存储用户名和密码相关信息的文件。

#### 关于 `.bat` 文件相关操作
- `echo set username=%%0 >username.bat`:这行是在创建 `username.bat` 文件并向其中写入内容 `set username=%0`,`%0` 在批处理中表示当前批处理文件的文件名。
- `echo set password=%%0 > password.bat`:同理,是创建 `password.bat` 文件并写入 `set password=%0`。
- `find namepass.txt /i "username" >temp1.bat`:这行是在 `namepass.txt` 文件中查找包含 `username`(不区分大小写 `/i`)的内容,并将结果输出到 `temp1.bat` 文件中。不过后面 `find namepass. ...` 看起来可能是内容没完整显示,推测是继续从 `namepass.txt` 文件中查找相关内容并输出到其他批处理文件中,整体这些批处理操作可能是在从 `namepass.txt` 文件中提取用户名和密码相关信息并进行存储或进一步处理的操作。

但是由于你提供的内容有部分不完整(`find namepass. ...` 没完整显示),所以只能大致解释到这里。

The following is the translation of the relevant explanation part:

First, look at the first part:

#### Regarding the content of the `namepass.txt` file
The `namepass.txt` file has two lines of content, namely `username` and `password`, which should be used to store information related to the username and password.

#### Regarding the relevant operations of the `.bat` file
- `echo set username=%%0 >username.bat`: This line is to create the `username.bat` file and write the content `set username=%0` into it. In batch processing, `%0` represents the file name of the current batch processing file.
- `echo set password=%%0 > password.bat`: Similarly, it is to create the `password.bat` file and write `set password=%0` into it.
- `find namepass.txt /i "username" >temp1.bat`: This line is to find the content containing `username` (case-insensitive `/i`) in the `namepass.txt` file and output the result to the `temp1.bat` file. However, the subsequent `find namepass. ...` seems to be that the content is not completely displayed. It is speculated that it is to continue to find relevant content from the `namepass.txt` file and output it to other batch processing files. In general, these batch processing operations may be operations of extracting relevant information of the username and password from the `namepass.txt` file and storing or further processing it. But since part of your provided content is incomplete (`find namepass. ...` is not completely displayed), so it can only be roughly explained here.
Floor 17 Posted 2006-10-18 00:03 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

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 18 Posted 2006-10-18 00:47 ·  中国 上海 漕河泾科技网IDC机房
新手上路
Credits 9
Posts 5
Joined 2006-10-11 05:17
19-year member
UID 65272
Status Offline
Floor 19 Posted 2006-10-18 01:21 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by NaturalJ0 at 2006-9-1 17:14:

I don't understand this code. What function does it perform? Can you explain it to me?

I don't quite understand either?

Why create the username.bat and password.bat files, and then delete them directly without calling them?
Floor 20 Posted 2006-10-18 05:26 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
当时没看懂,现在过了N天了,回头来看,才发现经典。
Forum Jump: