![]() |
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-08-18 21:18 |
47,814 topics / 349,908 posts / today 1 new / 48,259 members |
| DOS批处理 & 脚本技术(批处理室) » Ask about reading the content of a txt file into a variable under pure DOS |
| Printable Version 5,759 / 19 |
| Floor1 NaturalJ0 | Posted 2006-08-15 16:21 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
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 ] |
|
| Floor2 chenall | Posted 2006-08-16 16:08 |
| 银牌会员 Posts 469 Credits 1,276 From 福建泉州 | |
|
It is suggested to search the forum first. It seems there are many introductions. You can use programs like LMOD, strings, etc.
|
|
| Floor3 BAT | Posted 2006-08-16 23:04 |
| 初级用户 Posts 52 Credits 177 | |
|
Can you read file content into a variable without using third - party tools?
|
|
| Floor4 vkill | Posted 2006-08-22 12:13 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
What is the content of your file?
|
|
| Floor5 piziliu2004 | Posted 2006-08-22 18:14 |
| 中级用户 Posts 139 Credits 321 | |
|
It is suggested to make a small tool by yourself with TC. It can be realized with just a dozen of lines of code.
|
|
| Floor6 NaturalJ0 | Posted 2006-08-22 22:31 |
| 银牌会员 Posts 533 Credits 1,181 | |
Originally posted by piziliu2004 at 2006-8-22 18:14: What I did later was exactly like this. |
|
| Floor7 vkill | Posted 2006-08-25 12:06 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
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
|
|
| Floor8 wang6610 | Posted 2006-08-27 22:37 |
| 银牌会员 Posts 488 Credits 1,246 | |
Originally posted by NaturalJ0 at 2006-8-22 10:31 PM: Can you post it? |
|
| Floor9 wang6610 | Posted 2006-08-27 22:40 |
| 银牌会员 Posts 488 Credits 1,246 | |
Originally posted by he200377 at 2006-8-25 12:06 PM:
Just these two lines, how to write the batch script? Thanks! |
|
| Floor10 NaturalJ0 | Posted 2006-08-27 23:59 |
| 银牌会员 Posts 533 Credits 1,181 | |
Originally posted by wang6610 at 2006-8-27 22:37: 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 ] |
|
| Floor11 wang6610 | Posted 2006-08-28 07:11 |
| 银牌会员 Posts 488 Credits 1,246 | |
|
What is the name of the DOS variable to which PASSWORD.EXE assigns the read string?
|
|
| Floor12 NaturalJ0 | Posted 2006-08-28 08:31 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
PASSWORD.EXE is not assigned.
If you need to assign it, just assign it according to the status yourself. |
|
| Floor13 vkill | Posted 2006-08-28 12:58 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
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 |
|
| Floor14 wang6610 | Posted 2006-09-01 15:41 |
| 银牌会员 Posts 488 Credits 1,246 | |
Originally posted by he200377 at 2006-8-28 12:58 PM: 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 ] |
|
| Floor15 namejm | Posted 2006-09-01 16:01 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
Originally posted by wang6610 at 2006-9-1 15:41: 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 ] |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |