Solved

Output

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

912 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

19 Experts available now in Live!

Get 1:1 Help Now