0

I have a big batch file with PING and Iperf tests and it works, everything is written in a .txt file, I only want to see what is going on in the PING test for example, apparently >> command only writes to the text file. My solution is to send one time the PING without the >> to write to the file and another one with the >> to write to the file but this takes a lot of time for the purpose of the batch file.

Can anyone help me with a simpler solution?

thanks here is part of the code:

ECHO.
(
ECHO Test started on %DATE% %TIME%

C:\Windows\System32\ping.exe %SERVER% | findstr /r /c:"[0-9] *ms"

if %errorlevel% == 0 (
    echo.
    echo TEST de PING OK ! next test iPERF
) else (
    echo TEST de PING NOK
    ECHO Done
    PAUSE
    EXIT
)
) >> "%LOGFILE%.client.log"

1 Answers1

0

There is a special device con, which is essentially your command line window.

( 
echo this goes to file
>con echo this goes to screen explicitely
echo this goes to file too
)>file.log
Stephan
  • 53,940
  • 10
  • 58
  • 91
  • Actually what I want is to print in prompt and at the same time copy to the file – Filipe Lopes Aug 03 '17 at 11:45
  • then you need either an external tool (google for `tee for windows`) or [a weird batch solution](https://stackoverflow.com/a/15553922/2152082). I'd recommend the external tool. – Stephan Aug 03 '17 at 12:17