Solved

Output

Posted on 2007-03-27
5
240 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Show hidden user account 7 27
Novice question on VBScript 8 38
I want to make a copying program for vbs 1 26
Messed up my code 6 21
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

757 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

22 Experts available now in Live!

Get 1:1 Help Now