Link to home
Start Free TrialLog in
Avatar of Simon336697
Simon336697Flag for Australia

asked on

Output

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




Avatar of sirbounty
sirbounty
Flag of United States of America image

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...
Avatar of Simon336697

ASKER

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


ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanx again! :^)