Saved Bookmarks
| 1. |
Solve : how to capture the echo display and put it in file? |
|
Answer» HI.. im tryin to capture the echo display file like .. "The comman completed succesfully", etc. and put in the text. using the ">" operator. i want to create a log file. this will enable me to check if there is an failed or succes on my list of command... can anybody help me. thanks.. and more power.You want something such as : echo Commands succesful>Myfile.txt If it's that... you can also do something like this : %Directory%="C:\MyFolder\Myfile.txt" echo text...>%Directory% Or you can just don't use a var... Quote hi.. Uh, what is the PROBLEM? Have you tried this and it failed? Only thing I can think of is that your problem is that you keep getting a one-line log. To overcome that, use ">>" instead of ">". Mac Quote hi.. actually i have no problem using that ">" and ">>" operator providing im going to type the text... i have a batch file and echo on on the top of it.. next of it was a series of command like copy, net use.. etc.. after which each command it will echo WHETHER it is successful or not. that what im trying to capture. and save it just like a log file. thus it will enable me to check what happen to my command.. thanks.. again..You claim you know enough to code this Code: [Select]echo off echo Just some test data>zTest1.txt REM That is just to have a demo file date /t>>Log.txt time /t>>Log.txt copy zTest1.txt zTest2.txt>>Log.txt copy zTest2.txt+zTest2.txt zTest1.txt>>Log.txt type zTest1.txt erase zTest*.txt>>Log.txt Yet it is still something you don't want. Why?? I'm going to guess that you want the echoed commands to applear in the log. OK, code this Code: [Select]echo on echo Just some test data>zTest1.txt REM That is just to have a demo file date /t time /t copy zTest1.txt zTest2.txt copy zTest2.txt+zTest2.txt zTest1.txt type zTest1.txt erase zTest*.tx Here, commands without the will go into a log if you envoke the BAT file like this z>Log.txt (where z.bat is the file) Or if you don't want to remember that and you don't want two files, use this Code: [Select]echo on echo Just some test data>zTest1.txt REM That is just to have a demo file if x%1==xDoLog goto OK %0 DOLOG>Log.txt :OK date /t time /t copy zTest1.txt zTest2.txt copy zTest2.txt+zTest2.txt zTest1.txt type zTest1.txt erase zTest*.txt Mac I should add that if you also want to trap error messages, add "2>&1". Here is an example with errors. Mac if not x%1==xDoLog %0 DoLog>Log.txt 2>&1 date /t time /t copy zTest1.txt zTest2.txt erase zTest2.txt Quote I should add that if you also want to trap error messages, add "2>&1". Here is an example with errors. mac thank you very much to your reply i really appreciate it. i attached screen capture to show you what i really want is it really possible.. thanks you again.. Quote thank you very much to your reply i really appreciate it. just do this : net use d: \\help\share >> test123.txt 2>&1 that was working perfectly thanks a lot.... |
|