Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Output

Posted on 2007-03-27
5
244 Views
Last Modified: 2012-05-05
Hi guys!

We have a need to be able to do the following for example.

Run a script from a command window
See the script run with all output from that window
Log ALL output eg.exactly what is seen while looking at the window, in a text file.

For example:

cmd
C:\Documents and Settings\Owner>ping dell101

Pinging dell101 [192.168.0.2] with 32 bytes of data:

Reply from 192.168.0.2: bytes=32 time<1ms TTL=128
Reply from 192.168.0.2: bytes=32 time<1ms TTL=128
Reply from 192.168.0.2: bytes=32 time<1ms TTL=128
Reply from 192.168.0.2: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.0.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

All the above to be shown in a text file, including the command used to generate the replies.

Is there a way to do:
1) Get all the screen in an output file including commands entered and output
2) To also, while you are in the command window, to have the normal output displayed as well, so a duplicate of what will be written to the output file?

Thanks guys any help very much appreciated.

S




0
Comment
Question by:Simon336697
  • 4
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18805515
There's a tool called tee (http://unxutils.sourceforge.net/) that will allow you to do that...

To redirect output simply use

ping hostname > output.txt

But to see it both on the screen and log it in a file, you can use tee...
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18805527
0
 
LVL 1

Author Comment

by:Simon336697
ID: 18805563
Hi SB!

Thank you for that.

If I use:

ping hostname > output.txt

The output.txt has:



Pinging dell101 [192.168.0.2] with 32 bytes of data:



Reply from 192.168.0.2: bytes=32 time<1ms TTL=128

Reply from 192.168.0.2: bytes=32 time<1ms TTL=128



Ping statistics for 192.168.0.2:

    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 0ms, Average = 0ms

===============================================

Is there a way of getting the output.txt to display also the command you executed?

Would you have to set up 2 batch files to do this and call one from the other?

Thx SB


0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18805573
Usage would be nice - sorry about that! :^)

You would use

ping dell101 | tee output.txt

it would display both on-screen and results in output.txt
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18846472
Thanx again! :^)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

856 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