Solved

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

Posted on 2011-03-15
6
354 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 83

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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
How can you create a game plan that lets you focus on special projects instead of running from cubicle to cubicle every day and feeling like you’ve accomplished nothing? Try these strategies for prioritizing your tasks, offloading what you can, and …
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…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now