![]() |
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-12 00:48 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » [Original] Simulating command-line handle operations (to help understand handle copying and backup) |
| Printable Version 1,031 / 5 |
| Floor1 qzwqzw | Posted 2009-06-12 11:55 |
| 银牌会员 Posts 636 Credits 2,343 | |
| Floor2 s11ss | Posted 2009-06-13 12:36 |
| 银牌会员 Posts 566 Credits 2,098 | |
So how do you tell what a handle points to? I didn't understand this part. |
|
| Floor3 qzwqzw | Posted 2009-06-13 21:11 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
A typo correction:
echo 1&handle number to test is con should be echo 1<&handle number to test is con It is equivalent to echo is con 1<&handle number Example analysis: 1<&7 means copying what handle 7 points to into handle 1. And the output of echo is sent through handle 1 by default. So if handle 7 points to con, after copying it to 1, then 1 also points to con. Then the output of echo will appear on the screen. Otherwise it will not appear on the screen. Of course, this is only a simple way to tell con from non-con. For more specific methods, you'll still need to do more testing yourself. [ Last edited by qzwqzw on 2009-6-13 at 21:14 ] |
|
| Floor4 s11ss | Posted 2009-06-14 04:32 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by qzwqzw at 2009-6-13 09:11 PM: <& seems to be the same as >&, both copy the latter handle to the former handle. |
|
| Floor5 qzwqzw | Posted 2009-06-14 21:18 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
Now I found that the only difference between >& and <&
is the default value on the left side. The default left value of >& is 1. The default left value of <& is 0. The resulting effect is that after echo. >nul 3>nul makes handle 1 become nul, echo Hello Handle <&2 has no output echo Hello Handle >&2 has output |
|
| Floor6 s11ss | Posted 2009-06-14 23:11 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by qzwqzw at 2009-6-14 09:18 PM: hh ntcmds.chm::/redirection.htm If no handle is defined, the default handle for the < redirection input operator is 0, and the default handle for the > redirection output operator is 1. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |