|  | 
 
| IceFire 初级用户
 
   
 
 
 积分 104
 发帖 1
 注册 2004-3-4
 状态 离线
 | 
| 『楼 主』:
 如何将DOS的错误提示打印到一个txt文件里?
 
使用 LLM 解释/回答一下 
 
 
比如我运行一个自编的程序内容是将一个文件从一个目录COPY到另一个目录. 当该文件不存在时,DOS会提示说找不到文件.
 现在我想将DOS提示的信息打印到一个txt文件中
 
 应该怎么做呢?
 
For example, I run a self-written program whose content is to COPY a file from one directory to another. When the file does not exist, DOS will prompt that the file is not found. Now I want to print the DOS prompt information into a txt file. How should I do it?  
 
 
 |  | 
|  2004-3-4 00:00 |  | 
|  | 
 
| gotomsdos 铂金会员
 
        C++启程者
 
 
 积分 5154
 发帖 1827
 注册 2003-7-18
 状态 离线
 | 
| 『第 2 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
试试这个个批处理@echo off
 copy \1dir\1.ext 2dir>3.txt
 
 
Try this batch script  @echo off
 copy \1dir\1.ext 2dir>3.txt
 
 
 
 |  | 
|  2004-3-8 00:00 |  | 
|  | 
 
| qzwqzw 银牌会员
 
      天的白色影子
 
 
 积分 2343
 发帖 636
 注册 2004-3-6
 状态 离线
 | 
| 『第 3 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
gotomsdos 的方法不行 
The method of gotomsdos doesn't work 
 
 
 |  | 
|  2004-3-9 00:00 |  | 
|  | 
 
| mys 元老会员
 
          
 
 
 积分 5170
 发帖 1637
 注册 2002-10-16
 来自 广东佛山
 状态 离线
 | 
| 『第 4 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
这样行不行?if exist \1dir\1.ext  copy \1dir\1.ext 2dir>3.txt
 if not exist \1dir\1.ext  echo File not found.
 
Is this okay?if exist \1dir\1.ext  copy \1dir\1.ext 2dir>3.txt
 if not exist \1dir\1.ext  echo File not found.
 
 
 
 
 |  
                  |  我的网志
 http://hzmys.blog.163.com/
 我的网盘
 firststep.qjwm.com
 fsmys.ys168.com
 ssmys.ys168.com
 www.brsbox.com/fsmys
 www.brsbox.com/ssmys
 www.brsbox.com/ccdos
 
 |  | 
|  2004-3-9 00:00 |  | 
|  | 
 
| qzwqzw 银牌会员
 
      天的白色影子
 
 
 积分 2343
 发帖 636
 注册 2004-3-6
 状态 离线
 | 
| 『第 5 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
4楼的法子很取巧啊!可是这个File not found.不是copy发出的啊?不过,也好。如果楼主要求不高,这个也将就了。总比重定向错误设备要简单的多。 
The method on the 4th floor is quite tricky! But this "File not found" isn't from copy, though. Well, it's okay. If the poster doesn't have high requirements, this will do. It's much simpler than redirecting to an incorrect device. 
 
 
 |  | 
|  2004-3-10 00:00 |  | 
|  | 
 
| moroko 高级用户
 
     
 
 
 积分 919
 发帖 198
 注册 2004-1-17
 状态 离线
 |  | 
|  2004-3-11 00:00 |  | 
|  | 
 
| Climbing 铂金会员
 
        网络独行侠
 
 
 积分 6962
 发帖 2753
 注册 2003-4-16
 来自 河北保定
 状态 离线
 | 
| 『第 7 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
用lmod啊 
copy dir1\file1.ext dir2 > lmod /L*  > 3.txt
 
lmod是Horst Schaeffer的产品,他的产品好是好,但在中文系统下有些小问题(总出现Invalid keyboard code specified,然后就不能显示中文了),真希望他改进一下支持多国字符集。 
Contact -  Email: horst.schaeffer@gmx.net 
Homepage:  http://home.nikocity.de/horst.muc/int
Use lmod 
copy dir1\file1.ext dir2 > lmod /L*  > 3.txt
 
lmod is a product of Horst Schaeffer. His products are good, but there are some minor issues under Chinese systems (it always shows "Invalid keyboard code specified" and then Chinese cannot be displayed). I really hope he can improve to support multi-language character sets. 
Contact -  Email: horst.schaeffer@gmx.net 
Homepage:  http://home.nikocity.de/horst.muc/int
 
 
 
 |  
                  |  偶只喜欢回答那些标题和描述都很清晰的帖子!
 如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
 
 |  | 
|  2004-3-12 00:00 |  | 
|  | 
 
| Wengier 系统支持
 
              “新DOS时代”站长
 
 
 积分 27736
 发帖 10521
 注册 2002-10-9
 状态 离线
 | 
| 『第 8 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Horst的软件不用说了,他出的大多数软件,如WBAT等,均无法与汉字系统很好的配合。 
Horst's software needs no introduction. Most of his software, such as WBAT, cannot cooperate well with Chinese character systems. 
 
 
 
 |  
                  |  Wengier - 新DOS时代
 
 欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
 http://wendos.mycool.net/
 
 E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)
 
 
  |  | 
|  2004-3-12 00:00 |  | 
|  | 
 
| WisdomNil 新手上路
 
  
 
 
 
 积分 4
 发帖 2
 注册 2006-4-20
 状态 离线
 | 
| 『第 9 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
这个问题在纯DOS下就不能解决了?!
 我用del *.*命令时,如果目录下没有文件就有出错误提示,或文件不能删除也一样,用楼上的办法就搞不定了,希望高手指点!
 
Is this problem unsolvable under pure DOS?!
 When I use the del *.* command, if there are no files in the directory, there will be an error prompt, or if the file cannot be deleted, the same situation occurs. The method from the upstairs can't solve it, and I hope an expert can give guidance!
 
 
 
 |  | 
|  2006-4-20 16:50 |  | 
|  | 
 
| kcdsw 中级用户
 
    
 
 
 
 积分 404
 发帖 179
 注册 2006-3-30
 状态 离线
 | 
| 『第 10 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
帅哥~~试试这个 copy ..\楼主是帅哥.txt 2>帅哥是楼主.txt
 
Handsome guy~~ Give this a try copy ..\楼主是帅哥.txt 2>帅哥是楼主.txt
 
 
 
 |  | 
|  2006-4-21 16:11 |  | 
|  | 
 
| tsenix 初级用户
 
   
 
 
 
 积分 121
 发帖 61
 注册 2006-4-18
 来自 HK
 状态 离线
 | 
| 『第 11 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
试试用errorlevel吧... 不过好像是把问题变得更复杂 
Try using errorlevel... But it seems to make the problem more complicated 
 
 
 |  | 
|  2006-4-25 00:51 |  | 
|  | 
 
| willsort 元老会员
 
          Batchinger
 
 
 积分 4432
 发帖 1512
 注册 2002-10-18
 状态 离线
 | 
| 『第 12 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Re WisdomNil:
 因为在DOS中,错误设备不能被显式的重定向,同时del/dir等内部命令因为并非使用INT 21/AH=4Ch退出,因此出错时不会产生errrorlevel。
 
 所以,迄今为止,在DOS命令行或批处理中实现错误转向文件输出是未解决的问题。我目前所想到的思路,是使用debug汇编脚本重定向错误设备或者截取屏幕缓冲区的输出到文件中,但是实现起来比较困难。
 
Re WisdomNil:
 Because in DOS, the error device cannot be explicitly redirected, and internal commands such as del/dir do not exit using INT 21/AH=4Ch, so no errorlevel is generated when an error occurs.
 
 Therefore, so far, implementing error redirection to file output in the DOS command line or batch processing is an unsolved problem. The idea I have so far is to use a debug assembly script to redirect the error device or intercept the output of the screen buffer to a file, but it is relatively difficult to implement.
 
 
 
 
 |  
                  |  ※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
 |  | 
|  2006-4-25 17:19 |  | 
|  | 
 
| arding 初级用户
 
   
 
 
 
 积分 90
 发帖 38
 注册 2006-1-6
 状态 离线
 | 
| 『第 13 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Originally posted by kcdsw at 2006-4-21 16:11:帅哥~~试试这个
 
 copy ..\楼主是帅哥.txt 2>帅哥是楼主.txt
 
 
经过试验,发现所谓错误有两种: 
1。命令本身错误 
2。参数错误
 @echo offecho 参数错误:>帅哥是楼主i.txt
 echo ____________________>帅哥是楼主j.txt
 echo 命令本身错误:>>帅哥是楼主j.txt
 coby ..\楼主是帅哥.txt>>帅哥是楼主i.txt 2>>帅哥是楼主j.txt
 ::^^
 copy 帅哥是楼主i.txt+帅哥是楼主j.txt errsum.txt
 msg *<errsum.txt
 del 帅哥是楼主i.txt
 del 帅哥是楼主j.txt
 del errsum.txt
 
 
1。命令本身错误 的出错信息能被"2>"得到; 
2。参数错误       的出错信息能被">"得到;
 
 Last edited by arding on 2006-5-11 at 15:59 ] 
Originally posted by kcdsw at 2006-4-21 16:11:Hey guy~~ Try this
 
 copy ..\楼主是帅哥.txt 2>帅哥是楼主.txt
 
 
After testing, it is found that there are two types of so-called errors: 
1. Command itself error 
2. Parameter error
 @echo offecho Parameter error:>帅哥是楼主i.txt
 echo ____________________>帅哥是楼主j.txt
 echo Command itself error:>>帅哥是楼主j.txt
 coby ..\楼主是帅哥.txt>>帅哥是楼主i.txt 2>>帅哥是楼主j.txt
 ::^^
 copy 帅哥是楼主i.txt+帅哥是楼主j.txt errsum.txt
 msg *<errsum.txt
 del 帅哥是楼主i.txt
 del 帅哥是楼主j.txt
 del errsum.txt
 
 
1. The error message of "Command itself error" can be obtained by "2>"; 
2. The error message of "Parameter error" is obtained by ">";
 
 Last edited by arding on 2006-5-11 at 15:59 ] 
 
 
 |  | 
|  2006-5-11 15:52 |  | 
|  | 
 
| willsort 元老会员
 
          Batchinger
 
 
 积分 4432
 发帖 1512
 注册 2002-10-18
 状态 离线
 | 
| 『第 14 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Re arding:
 所有错误,无论是无效命令名错误、无效命令参数错误还是命令执行过程中错误,均可分为两类:向标准错误stderr发出的和向标准输出stdout发出的。二者虽然缺省均指向控制台设备,但它们使用的仍然是不同的端口。
 
 而 cmd 的 copy 命令是有些特殊的,因为它将许多错误都通过标准输出发出,所以我们用>file对这些错误信息进行重定向,但DOS和CMD下的大多数命令其错误信息通常都通过标准错误发出的。因此,你的二分法不具有普遍意义。
 
 另外,楼主讨论的错误重定向至今仍限定在DOS环境下,CMD环境下的2>是不予讨论的。
 
Re regarding:
 All errors, whether they are errors of invalid command names, invalid command parameters, or errors during command execution, can be divided into two categories: those sent to standard error stderr and those sent to standard output stdout. Although both default to pointing to the console device, they use different ports.
 
 And the copy command of cmd is somewhat special because it sends many errors through standard output, so we use >file to redirect these error messages, but most commands under DOS and CMD usually send error messages through standard error. Therefore, your dichotomy is not universal.
 
 In addition, the error redirection discussed by the original poster is still limited to the DOS environment, and 2> in the CMD environment is not discussed.
 
 
 
 
 |  
                  |  ※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
 |  | 
|  2006-5-11 19:53 |  | 
|  | 
 
| arding 初级用户
 
   
 
 
 
 积分 90
 发帖 38
 注册 2006-1-6
 状态 离线
 | 
| 『第 15 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
有点明白。我这里不方便使用纯DOS,而且也从来没有深究这些细节。你的意思是不是集中在这句话: 大多数命令其错误信息通常都通过标准错误发出的
 
 
如果这样,是不是用ERRORLEVEL或者2>就可以捕获几乎所有错误?
 
 Last edited by arding on 2006-5-12 at 09:28 ]
Got it a bit. I don't have easy access to pure DOS here, and I've never delved deeply into these details. Do you mean focusing on this sentence: Most commands usually emit their error messages through standard error.
 
 
If that's the case, can  capture almost all errors using ERRORLEVEL or 2>?
 
 Last edited by arding on 2006-5-12 at 09:28 ]
 
 
 |  | 
|  2006-5-12 09:24 |  |