Solved

Output

Posted on 2007-03-27
5
246 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
[X]
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
  • 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

635 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