![]() |
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-07 07:58 |
48,040 topics / 350,125 posts / today 1 new / 48,252 members |
| DOS批处理 & 脚本技术(批处理室) » Question: how to save the result of executing a command into a variable |
| Printable Version 954 / 5 |
| Floor1 biwier | Posted 2007-10-16 13:38 |
| 初级用户 Posts 34 Credits 98 | |
|
For example:
save the result of the hostname command into the hn variable.. set hn=`hostname` under XP,, this doesn't work |
|
| Floor2 不得不爱 | Posted 2007-10-16 17:56 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
| Floor3 knoppix7 | Posted 2007-10-16 18:10 |
| 银牌会员 Posts 634 Credits 1,287 From cmd.exe | |
|
Seems like someone asked this before.
|
|
| Floor4 lxmxn | Posted 2007-10-17 02:30 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Hehe, OP, have you been using Shell too much?
|
|
| Floor5 plp626 | Posted 2008-01-22 00:19 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
Why not use the for command to get it directly? I feel like using the pipe symbol should work, but my tests never succeed.
Assign the result of find /c /v "" test.txt to the variable line, using set line=|echo|find /c /v "" test.txt why doesn't it work? |
|
| Floor6 knoppix7 | Posted 2008-01-22 10:25 |
| 银牌会员 Posts 634 Credits 1,287 From cmd.exe | |
|
Did the poster above try it?
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |