Advertisement

06.09.2008 at 09:22AM PDT, ID: 23469608
[x]
Attachment Details

How To Output a Message to Both a File and Console

Asked by michael4606 in Microsoft Server, MS DOS, Windows 2003 Server

Tags: , , ,

Hello,

In a DOS\Console batch file I need to output all information (standard output and error output) to both the screen AND a log type file.  Ideally I Do NOT want to use two lines every time I need to output a message (one to screen and one to file - yuk).  Here is an example output line:

set MYFILE=c:\temp\myfile.log
set FILE_TYPE=Export
echo %time% - Transferring %FILE_TYPE%

I know I can append this to a file using:
echo %time% - Transferring %FILE_TYPE% >> %MYFILE%

OR even

echo %time% - Transferring %FILE_TYPE% >> %MYFILE% 2>&1

My problem is if the above is used I do not get any screen output.  I feel I am close.

What can you suggestion?

Thanks,

Michael4606



When I do this I cannot
Start Free Trial
[+][-]06.09.2008 at 09:32AM PDT, ID: 21744498

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.09.2008 at 02:02PM PDT, ID: 21746652

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Server, MS DOS, Windows 2003 Server
Tags: Microsoft, Windows, 2003 Server, Batch File
Sign Up Now!
Solution Provided By: dragon-it
Participating Experts: 2
Solution Grade: B
 
 
[+][-]06.12.2008 at 12:54PM PDT, ID: 21773076

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628