[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Logging a batch file

Posted on 2001-07-19
31
Medium Priority
?
51 Views
Last Modified: 2013-12-28
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

0
Comment
Question by:cma1
  • 7
  • 6
  • 6
  • +6
31 Comments
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6300947
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
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6300951
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
 

Author Comment

by:cma1
ID: 6301051
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Expert Comment

by:kahlean
ID: 6301058
/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
 
LVL 12

Expert Comment

by:Otta
ID: 6301170
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
 

Author Comment

by:cma1
ID: 6302152
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
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6302310
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
 
LVL 12

Expert Comment

by:Otta
ID: 6302334
> 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
 

Author Comment

by:cma1
ID: 6302487
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
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6302530
How about showing use the content of your bat file it might help aid us in finding a solution.
0
 
LVL 2

Expert Comment

by:nfernand
ID: 6302589
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
 

Author Comment

by:cma1
ID: 6302951
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
 
LVL 2

Expert Comment

by:nfernand
ID: 6303007
The help from CrazyOne works for me... even it doesn't work out of the .bat

Isn't it enough?
0
 
LVL 2

Expert Comment

by:nfernand
ID: 6303014
Ok... this may works:

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

0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6303115
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
 

Author Comment

by:cma1
ID: 6303175
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
 

Author Comment

by:cma1
ID: 6303188
This is really a DOS question.
0
 
LVL 12

Expert Comment

by:Otta
ID: 6304343
> 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
 
LVL 7

Expert Comment

by:WiZaRd
ID: 6305472
you said it yourself !
have you posted this one in the Dos section ?
0
 
LVL 12

Expert Comment

by:Otta
ID: 6306629
Use the 'CTTY' ("change TTY") to divert _all_ output.

Run your '.BAT' file.

Use 'CTTY' to "cancel" the diversion.

Works under DOS!
0
 

Author Comment

by:cma1
ID: 6307192
deleted and went to DOS forum
0
 
LVL 12

Expert Comment

by:Otta
ID: 6310920
It's curious that there is no reference to 'CTTY' in your "DOS" question _UNTIL_ Otta mentioned 'CTTY' in this question.

Plagiarism?????
0
 

Expert Comment

by:lishu
ID: 6327981
Right click on the dos prompt. in properties there is an option of screen check the following according to your suitability
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6388279
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
 

Expert Comment

by:ComTech
ID: 6400409
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
 
LVL 6

Expert Comment

by:Triskelion
ID: 6401894
Well, the question can still be deleted.
0
 
LVL 12

Expert Comment

by:Otta
ID: 6401906
Well, the question can still be manipulated by "accept-comment-as-answer",
to reward E-E experts for their efforts.
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6402129
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
 
LVL 6

Expert Comment

by:Triskelion
ID: 6402140
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
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6402205
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
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6402601
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I read that Microsoft has analysed statistics for their security intelligence report. It revealed: still, the clear majority of windows users do their daily work as administrator. An administrative account is a burden, security-wise. My ar…
A simple method to resolve a "keyboard not working" problem by modifying the Windows registry. This issue can often be encountered after using the VMware vCenter Converter Standalone Agent to perform a Physical-to-Virtual (P2V) conversion process.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question