|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『楼 主』:
请教纯DOS下读取txt文件内容至变量
使用 LLM 解释/回答一下
我翻了些论坛的帖,发现FOR在纯DOS下功能不够用。又有达人提到使用第三方软件或其它方法。能给小弟一个第三方软件和简单使用方法吗?非常感谢。
Last edited by NaturalJ0 on 2006-8-15 at 16:22 ]
I've gone through some forum posts and found that FOR in pure DOS is not sufficient in functionality. Some experts mentioned using third-party software or other methods. Could you provide me with a third-party software and a simple usage method? Thanks a lot.
Last edited by NaturalJ0 on 2006-8-15 at 16:22 ]
|
|
2006-8-15 16:21 |
|
|
chenall
银牌会员
    
积分 1276
发帖 469
注册 2002-12-23 来自 福建泉州
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
建议先搜一下论坛.好像有许多介绍的.
可以使用LMOD,strings等程序.
It is suggested to search the forum first. It seems there are many introductions. You can use programs like LMOD, strings, etc.
|

QQ:366840202
http://chenall.net |
|
2006-8-16 16:08 |
|
|
BAT
初级用户
 
积分 177
发帖 52
注册 2006-6-4
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
是否可以不用三方工具来实现读取文件内容至变量
Can you read file content into a variable without using third - party tools?
|
|
2006-8-16 23:04 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
|
2006-8-22 12:13 |
|
|
piziliu2004
中级用户
   过度热情
积分 321
发帖 139
注册 2006-3-21
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
建议自己用tc做一个小tool. 很简单的十几行代码就可实现.
It is suggested to make a small tool by yourself with TC. It can be realized with just a dozen of lines of code.
|
|
2006-8-22 18:14 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Originally posted by piziliu2004 at 2006-8-22 18:14:
建议自己用tc做一个小tool. 很简单的十几行代码就可实现.
我后来就是这么做的。
Originally posted by piziliu2004 at 2006-8-22 18:14:
It is suggested to make a small tool by yourself with TC. It can be realized with just more than a dozen lines of code.
What I did later was exactly like this.
|
|
2006-8-22 22:31 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
把你的txt文件内容帖出来,想把什么做为变量,给你批处理,不用第三方软件的
Post the content of your txt file. If you want to use something as a variable, give me the batch processing without using third-party software
|
|
2006-8-25 12:06 |
|
|
wang6610
银牌会员
    
积分 1246
发帖 488
注册 2003-11-11
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Originally posted by NaturalJ0 at 2006-8-22 10:31 PM:
我后来就是这么做的。
能把它帖出来吗?
Originally posted by NaturalJ0 at 2006-8-22 10:31 PM:
I did it like this later.
Can you post it?
|
|
2006-8-27 22:37 |
|
|
wang6610
银牌会员
    
积分 1246
发帖 488
注册 2003-11-11
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by he200377 at 2006-8-25 12:06 PM:
把你的txt文件内容帖出来,想把什么做为变量,给你批处理,不用第三方软件的
username
password
就这两行,批处理该怎么写?
谢谢!
Originally posted by he200377 at 2006-8-25 12:06 PM:
Post the content of your txt file. What do you want to use as variables, and I'll write a batch script for you, without using third-party software
username
password
Just these two lines, how to write the batch script?
Thanks!
|
|
2006-8-27 22:40 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
Originally posted by wang6610 at 2006-8-27 22:37:
能把它帖出来吗?
好的。
我原来是想要个密码功能,自己用 TC 写了个,在这里。
http://zhenlove.com.cn/cndos/fileup/files/PASSWORD.rar
里面是 PASSWORD.EXE
运行时在同目录查找 PASSWORD.TXT ,并读取其内容为原始密码。
读取时从文件开始读取至第一个回车,回车前可以有空格和符号等。
然后要求用户输入密码与原始密码进比较。
如果相同,在同目录生成 PASSWORD.OK 文件。
如果不同,在同目录生成 PASSWORD.ERR 文件。
以上两种情况属正常运行,都会再生成一个 PASSWORD.RUN 文件,若用户按 Ctrl + C 强制中断,则此文件将不会生成。
使用时可以在 BAT 中使用 echo "Your Password">PASSWORD.TXT 来设置原始密码。
然后根据三个状态文件的生成情况判断处理。连续使用的时候时要自己删除状态表示文件。
Last edited by NaturalJ0 on 2006-8-28 at 00:01 ]
Originally posted by wang6610 at 2006-8-27 22:37:
Can you post it?
Okay.
I originally wanted a password function, and I wrote one myself with TC, here it is.
http://zhenlove.com.cn/cndos/fileup/files/PASSWORD.rar
Inside is PASSWORD.EXE
When running, it looks for PASSWORD.TXT in the same directory and reads its content as the original password.
When reading, it reads from the beginning of the file to the first carriage return, and there can be spaces and symbols before the carriage return.
Then it asks the user to enter the password to compare with the original password.
If they are the same, a PASSWORD.OK file is generated in the same directory.
If they are different, a PASSWORD.ERR file is generated in the same directory.
Both of these situations are normal operations, and a PASSWORD.RUN file will be generated in both cases. If the user presses Ctrl + C to forcefully interrupt, this file will not be generated.
When using it, you can use echo "Your Password">PASSWORD.TXT in the BAT to set the original password.
Then judge and handle according to the generation of the three status files. When using continuously, you need to delete the status indicator files yourself.
Last edited by NaturalJ0 on 2006-8-28 at 00:01 ]
|
|
2006-8-27 23:59 |
|
|
wang6610
银牌会员
    
积分 1246
发帖 488
注册 2003-11-11
状态 离线
|
|
2006-8-28 07:11 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
PASSWORD.EXE 没赋。
要赋的话自己根据状态赋好了。
PASSWORD.EXE is not assigned.
If you need to assign it, just assign it according to the status yourself.
|
|
2006-8-28 08:31 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
namepass.txt
username
password
*.bat
echo set username=%%0 >username.bat
echo set password=%%0 > password.bat
find namepass.txt /i "username" >temp1.bat
find namepass.txt /i "password" >temp2.bat
call temp1.bat
call temp2.bat
del /q username.bat
del /q password.bat
del /q temp1.bat
del /q temp2.bat
echo %username% >>x.txt
echo %password% >>x.txt
不知道这样表达对不对
namepass.txt要是如下,则set 那就改为%%1
namepass.txt
username abc
password 123
namepass.txt要是如下,文件名中不让用:,我想可以用有个帖子的方法,大概是echo !%name:~0,-1%_ ! ,就是去掉:加一个空格,这样可以改为和上面的那个一样
namepass.txt
username:abc
password:123
namepass.txt
username
password
*.bat
echo set username=%%0 >username.bat
echo set password=%%0 > password.bat
find namepass.txt /i "username" >temp1.bat
find namepass.txt /i "password" >temp2.bat
call temp1.bat
call temp2.bat
del /q username.bat
del /q password.bat
del /q temp1.bat
del /q temp2.bat
echo %username% >>x.txt
echo %password% >>x.txt
I don't know if this expression is correct
If namepass.txt is as follows, then set should be changed to %%1
namepass.txt
username abc
password 123
If namepass.txt is as follows, colons are not allowed in the file name. I think there is a method in a certain post, probably echo !%name:~0,-1%_ !, which is to remove the colon and add a space, so that it can be changed to the same as the above one
namepass.txt
username:abc
password:123
|
|
2006-8-28 12:58 |
|
|
wang6610
银牌会员
    
积分 1246
发帖 488
注册 2003-11-11
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
Originally posted by he200377 at 2006-8-28 12:58 PM:
namepass.txt
username
password
*.bat
echo set username=%%0 >username.bat
echo set password=%%0 > password.bat
find namepass.txt /i "username" >temp1.bat
find namepass. ...
namepass.txt
username:abc
password:123
谢谢!
abc
123
它们后面多了两个空格,如何不让它多啊? 谢谢!
Last edited by wang6610 on 2006-9-1 at 15:44 ]
Originally posted by he200377 at 2006-8-28 12:58 PM:
namepass.txt
username
password
*.bat
echo set username=%%0 >username.bat
echo set password=%%0 > password.bat
find namepass.txt /i "username" >temp1.bat
find namepass. ...
namepass.txt
username:abc
password:123
Thank you!
abc
123
There are two extra spaces after them. How to prevent them from being added? Thank you!
Last edited by wang6610 on 2006-9-1 at 15:44 ]
|
|
2006-9-1 15:41 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
Originally posted by wang6610 at 2006-9-1 15:41:
谢谢!
abc
123
它们后面多了两个空格,如何不让它多啊? 谢谢!
Last edited by wang6610 on 2006-9-1 at 15:44 ]
把echo set username=%%0 >username.bat 改写成 echo (set username=%%0)>username.bat 或者 >username.bat echo set username=%%0
Last edited by namejm on 2006-11-5 at 12:21 PM ]
Originally posted by wang6610 at 2006-9-1 15:41:
Thanks!
abc
123
There are two extra spaces after them, how to prevent it from adding more? Thanks!
Last edited by wang6610 on 2006-9-1 at 15:44 ]
Change echo set username=%%0 >username.bat to echo (set username=%%0)>username.bat or >username.bat echo set username=%%0
Last edited by namejm on 2006-11-5 at 12:21 PM ]
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-1 16:01 |
|