cma1
asked on
Logging a batch file
When I run a batch file in WIN98-SE, the batch file DOS window scrolls by so fast that I cannot read it.
How can I get a log of the batch files results (like "xyz file not found")?
Thanks, CMA
How can I get a log of the batch files results (like "xyz file not found")?
Thanks, CMA
You can also try using this command to help view what is happening
pause
"Suspends processing of a batch program and displays the message
Press any key to continue . . ."
pause
"Suspends processing of a batch program and displays the message
Press any key to continue . . ."
ASKER
What I am looking for as sort of a combination of the two suggestions, e.g. the output of the file is sent to a .txt file, so that I would see various messages output by DOS, like "File not found" or File copied", etc.
So how could that be accomplished?
(I am not interested in directories, but rather in the output of the batch file.)
So how could that be accomplished?
(I am not interested in directories, but rather in the output of the batch file.)
/P Pauses after each screenful of information.
/W Uses wide list format.
/A Displays files with specified attributes.
D Directories R Read-only H Hidden files A Files ready for archiving S System files
/O List by files in sorted order.
N By name S By size (smallest first)
E By extension (alphabetic) D By date & time G Group directories first
for instant to run display after screen full
dir [directory location and name] /p
example
dir c:\windows /p
for a complete list you can type dir/?
Regards
p/s: Hi crazyone
/W Uses wide list format.
/A Displays files with specified attributes.
D Directories R Read-only H Hidden files A Files ready for archiving S System files
/O List by files in sorted order.
N By name S By size (smallest first)
E By extension (alphabetic) D By date & time G Group directories first
for instant to run display after screen full
dir [directory location and name] /p
example
dir c:\windows /p
for a complete list you can type dir/?
Regards
p/s: Hi crazyone
Command-line redirection.
* MYFILE > output.txt
runs 'MYFILE.BAT' and diverts all the "console" output into the file 'output.txt'.
* MYFILE | MORE
runs 'MYFILE.BAT' and diverts all the "console" output
into the 'MORE' program (which displays 20 lines,
and then pauses).
* MYFILE > output.txt
runs 'MYFILE.BAT' and diverts all the "console" output into the file 'output.txt'.
* MYFILE | MORE
runs 'MYFILE.BAT' and diverts all the "console" output
into the 'MORE' program (which displays 20 lines,
and then pauses).
ASKER
Everyone has some good ideas.
But for my actual situation, how would I solve it?
I have a batch file, "filescopy.bat"
How would I get the result of the output sent to a text file?
What line would I put in the batch file to accomplish this?
But for my actual situation, how would I solve it?
I have a batch file, "filescopy.bat"
How would I get the result of the output sent to a text file?
What line would I put in the batch file to accomplish this?
an example of copying the entire contents of one drive to another drive and dumping the results into a text file.
xcopy /e/h/k/c c:\*.* d: >c:\filecopy.txt
Hi kahlean :>)
xcopy /e/h/k/c c:\*.* d: >c:\filecopy.txt
Hi kahlean :>)
> I have a batch file, "filescopy.bat"
> How would I get the result of the output sent to a text file?
Type the command: filescopy > C:\FILE.TXT
to run 'filescopy.bat' and to write the output to the named file.
> How would I get the result of the output sent to a text file?
Type the command: filescopy > C:\FILE.TXT
to run 'filescopy.bat' and to write the output to the named file.
ASKER
Otta,
I ran from a DOS prompt
filecopy > c:\temp\output.txt
It creates a file "output.txt" of 0 bytes.
So there is no information provided.
I ran from a DOS prompt
filecopy > c:\temp\output.txt
It creates a file "output.txt" of 0 bytes.
So there is no information provided.
How about showing use the content of your bat file it might help aid us in finding a solution.
Use:
COmmand.com /y /c mybatch.bat
This makes a pause on every command in your batch so you can see what happens.
Bye.
COmmand.com /y /c mybatch.bat
This makes a pause on every command in your batch so you can see what happens.
Bye.
ASKER
The contents just copies files from one directory to another.
But some files may be missing, so the inds of messages that appear are"
"1 copy filed"
or "Access denied"
or "0 files copied"
But I want to see them in a .txt file as the batch file is so large, that Pause statements are not useful.
From: CrazyOne Date: 07/20/2001 07:58AM PST
How about showing use the content of your bat file it might help aid us in finding a solution.
Comment
But some files may be missing, so the inds of messages that appear are"
"1 copy filed"
or "Access denied"
or "0 files copied"
But I want to see them in a .txt file as the batch file is so large, that Pause statements are not useful.
From: CrazyOne Date: 07/20/2001 07:58AM PST
How about showing use the content of your bat file it might help aid us in finding a solution.
Comment
The help from CrazyOne works for me... even it doesn't work out of the .bat
Isn't it enough?
Isn't it enough?
Ok... this may works:
c:\>command.com /c batchfile.bat > log.txt
c:\>command.com /c batchfile.bat > log.txt
I think what cma1 is looking for is to just log the number(amount) of files copied and/or the errors but not list each individual file that was copied. I am not sure that can be done though.
ASKER
Yes, I am looking for a log file, which shows exactly what you see on the screen in the DOS box.
There should be a DOS command which sends the output of
the batch file to a .txt file.
But of course you have to run the batch file as part of the process.
Before the days of WIN95-98, there were probably lots of people who knew all about batch files, but I think that it is a lost art now.
think what cma1 is looking for is to just log the number(amount) of files copied and/or the errors
but not list each individual file that was copied. I am not sure that can be done though.
Here are your options, cma1
There should be a DOS command which sends the output of
the batch file to a .txt file.
But of course you have to run the batch file as part of the process.
Before the days of WIN95-98, there were probably lots of people who knew all about batch files, but I think that it is a lost art now.
think what cma1 is looking for is to just log the number(amount) of files copied and/or the errors
but not list each individual file that was copied. I am not sure that can be done though.
Here are your options, cma1
ASKER
This is really a DOS question.
> I am looking for a log file, which shows exactly
> what you see on the screen in the DOS box.
> There should be a DOS command which sends the output
> of the batch file to a .txt file.
To run 'MYPROG.BAT' and to write the output to 'MYOUT.TXT', enter:
MYPROG > MYOUT.TXT
That's all.
> what you see on the screen in the DOS box.
> There should be a DOS command which sends the output
> of the batch file to a .txt file.
To run 'MYPROG.BAT' and to write the output to 'MYOUT.TXT', enter:
MYPROG > MYOUT.TXT
That's all.
you said it yourself !
have you posted this one in the Dos section ?
have you posted this one in the Dos section ?
Use the 'CTTY' ("change TTY") to divert _all_ output.
Run your '.BAT' file.
Use 'CTTY' to "cancel" the diversion.
Works under DOS!
Run your '.BAT' file.
Use 'CTTY' to "cancel" the diversion.
Works under DOS!
ASKER
deleted and went to DOS forum
It's curious that there is no reference to 'CTTY' in your "DOS" question _UNTIL_ Otta mentioned 'CTTY' in this question.
Plagiarism?????
Plagiarism?????
Right click on the dos prompt. in properties there is an option of screen check the following according to your suitability
cma1, you may not be understanding the answer.
You have received the answer to this multiple times.
Use the redirect character ">" to place what would normally go to the screen into a file.
Try it.
There are still plenty of DOS experts around.
I am one of them.
You have received the answer to this multiple times.
Use the redirect character ">" to place what would normally go to the screen into a file.
Try it.
There are still plenty of DOS experts around.
I am one of them.
Duplicate post here: https://www.experts-exchange.com/jsp/qShow.jsp?ta=msdos&qid=20154458
ComTech
Community Support
cma1, as it stands, you are in for 200 points in this question, 100 here and 100 in MSDos Area.
It would be helpfull to get these questions to come to an end, and resolve both.
Thank you,
ComTech
Community Support Moderator
Ps. As it is now, I cannot delete either, as Experts have put time and effort into both.
ComTech
Community Support
cma1, as it stands, you are in for 200 points in this question, 100 here and 100 in MSDos Area.
It would be helpfull to get these questions to come to an end, and resolve both.
Thank you,
ComTech
Community Support Moderator
Ps. As it is now, I cannot delete either, as Experts have put time and effort into both.
Well, the question can still be deleted.
Well, the question can still be manipulated by "accept-comment-as-answer" ,
to reward E-E experts for their efforts.
to reward E-E experts for their efforts.
That's actually what I want to happen, but I was not the first to suggest the answer I would use.
(CrazyOne
hint, hint)
(CrazyOne
hint, hint)
The hint for CrazyOne is separate from the suggestion by Otta (accept-comment-as-answer) .
The opinions expressed in this post do not necessarily reflect the opinions of Experts-Exchange, it's supporters or the actual Experts. :-) All sales are final. Your mileage may vary. Use at your own risk. Avoid if you've been using an M.A.O. inhibitor.
The opinions expressed in this post do not necessarily reflect the opinions of Experts-Exchange, it's supporters or the actual Experts. :-) All sales are final. Your mileage may vary. Use at your own risk. Avoid if you've been using an M.A.O. inhibitor.
Umm well none of the comments in this Q actually do what cma1 wanted and I have tested them myself. There are two comments in the other Q that do work. One of which is this.
Expert Ugi
Command >>log.txt 2>>&1
and the other is
Expert rin1010
FOR %%x in (C:\Windows\*.*) do XCOPY /C %%x C:\BakupDir >> ~Results.txt
My thought is that cma1 wanted to delete this Q and I have no objection to it, since what cma1 was asking for is not here. Keep in mind cma1 was asking to have the errors logged and none of the comments in this Q did that, per my testing anyway. :>)
Expert Ugi
Command >>log.txt 2>>&1
and the other is
Expert rin1010
FOR %%x in (C:\Windows\*.*) do XCOPY /C %%x C:\BakupDir >> ~Results.txt
My thought is that cma1 wanted to delete this Q and I have no objection to it, since what cma1 was asking for is not here. Keep in mind cma1 was asking to have the errors logged and none of the comments in this Q did that, per my testing anyway. :>)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Let us say you want a list of directories then this is how it would be done
dir >c:\AnyDirerctory\dir.txt
You can name the file what you want and if you use the .txt extension then you can view the log in Notepad.
The Crazy One