Solved

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

Posted on 2011-03-15
6
351 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 76

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

As a long-time IT Professional, the most important skill I have developed and consider to be my most valuable tool is Effective Troubleshooting. Step through my problem-solving procedure in this 10-step guide adapted from The Universal Troubleshooti…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

12 Experts available now in Live!

Get 1:1 Help Now