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

cma1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CrazyOneCommented:
something like this:

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
0
CrazyOneCommented:
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 . . ."
0
cma1Author Commented:
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.)
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

kahleanCommented:
/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


0
OttaCommented:
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).
0
cma1Author Commented:
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?
0
CrazyOneCommented:
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 :>)
0
OttaCommented:
> 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.
0
cma1Author Commented:
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.
0
CrazyOneCommented:
How about showing use the content of your bat file it might help aid us in finding a solution.
0
nfernandCommented:
Use:

COmmand.com /y /c mybatch.bat

This makes a pause on every command in your batch so you can see what happens.

Bye.
0
cma1Author Commented:
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
0
nfernandCommented:
The help from CrazyOne works for me... even it doesn't work out of the .bat

Isn't it enough?
0
nfernandCommented:
Ok... this may works:

c:\>command.com /c batchfile.bat > log.txt

0
CrazyOneCommented:
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.
0
cma1Author Commented:
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  
0
cma1Author Commented:
This is really a DOS question.
0
OttaCommented:
> 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.
0
WiZaRdCommented:
you said it yourself !
have you posted this one in the Dos section ?
0
OttaCommented:
Use the 'CTTY' ("change TTY") to divert _all_ output.

Run your '.BAT' file.

Use 'CTTY' to "cancel" the diversion.

Works under DOS!
0
cma1Author Commented:
deleted and went to DOS forum
0
OttaCommented:
It's curious that there is no reference to 'CTTY' in your "DOS" question _UNTIL_ Otta mentioned 'CTTY' in this question.

Plagiarism?????
0
lishuCommented:
Right click on the dos prompt. in properties there is an option of screen check the following according to your suitability
0
TriskelionCommented:
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.
0
ComTechCommented:
Duplicate post here:  http://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.
0
TriskelionCommented:
Well, the question can still be deleted.
0
OttaCommented:
Well, the question can still be manipulated by "accept-comment-as-answer",
to reward E-E experts for their efforts.
0
TriskelionCommented:
That's actually what I want to happen, but I was not the first to suggest the answer I would use.

(CrazyOne
   hint, hint)
0
TriskelionCommented:
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.
0
CrazyOneCommented:
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. :>)
0
ComTechCommented:
As a customer request pending, and an ongoing question in the MSDos TA. this Q' will be PAQ'd for information leading to the other question, where shre seem to be a possible answer and a war of words.

Please see the URL I listed in my above comment if you wish to still participate.

Thanks,
ComTech
Community Support.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.