Solved

How can I echo all the console text to a log file while still displaying onscreen?

Posted on 2011-03-15
6
357 Views
Last Modified: 2012-05-11
I am looking for a way to fun a command from the command prompt and have all the output saved to a file.  But I do not want to supress the console display.  I want to see what is going on, but alos have a record of it for later.

Currently using a UNC to get to the executable:
C:\>\\Server\Share\Tools\updates\QC-updater.exe >>c:\temp\QC-updater.log 2>&1

It logs everything to a file, but won't display it on screen as well.

Thanks in advance!

Ed
0
Comment
Question by:ednetman
6 Comments
 
LVL 8

Expert Comment

by:ragnarok89
ID: 35141966
The only way I know is with 2 statements:

echo off
echo This is going to the screen.
@echo this is goinh to the log>>log.txt
0
 
LVL 84

Expert Comment

by:oBdA
ID: 35142274
You can do that with tee.exe, for example with the version included in the GNU utilities here:
GNU utilities for Win32
http://unxutils.sourceforge.net/

You just pipe the output of the command to tee.exe and tell tee.exe the file to write too.
If tee.exe file is in the same folder as the program above (-a appends to the file, default is to overwrite it):
\\Server\Share\Tools\updates\QC-updater.exe 2>&1 | \\Server\Share\Tools\updates\tee.exe -a C:\temp\QC-updater.log
0
 
LVL 7

Author Comment

by:ednetman
ID: 35142863
Hmm, Tee seems like a good option, but it's not going to be on the machines.  It would take time to allow that file to be on the server that houses the update executable, if it dever got approved.

I was hoping for something more command line based that is internal to the OS.
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
LVL 77

Accepted Solution

by:
arnold earned 250 total points
ID: 35144017
write to the file as you have and use tail -f to tail the file. Tail I think is part of the support tools or resource kit.
i.e.
open one command windows and run:
tail -f c:\temp\QC-updater.log
In another window run:
\\Server\Share\Tools\updates\QC-updater.exe >>c:\temp\QC-updater.log 2>&1
0
 
LVL 7

Author Comment

by:ednetman
ID: 35172513
I checked the desktops and file is not there. It is on the server, so I am going to try running it from there.
0
 
LVL 7

Author Comment

by:ednetman
ID: 35231817
Ok, I think that got it.  I see that tail has to be run in a seperate windows fromt eh actual commands, but I think I can work with that.
also, the log file has to exist BEFORE running tail.exe.  Again, no worries there.
I was able to run it from a network share with a mapped drive.  I need to test with a UNC, but if that doesn't work I can simply map a drive and disconnect when done.

This is pretty darn close to what I needed, and I think I can work with this.

Thanks for the help!

~Ed
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

#Citrix #POC #XenDesktop #vCenter #VMware #ESX
Are client relationship the only driver of a successful MSP? While important, client relationships are only one component. Learn how else MSPs can broaden their horizon and differentiate themselves.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

792 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