Answer the question
In order to leave comments, you need to log in
Why does findstr behave inappropriately in batch file?
Friends, good day!
We have a batch file
@set iptoping=127.0.0.1
@set pdir=C:\pinglog
@echo Пингуем %iptoping% пакетами по 5000 байт с выводом в %pdir%\ping_%iptoping%.log. Для завершения закройте окно.
@MD %pdir%
@>"%pdir%\ping_%iptoping%.log" (
for /l %%i in () do @>nul chcp 866& ping -l 5000 -n 1 %iptoping%| findstr /i "Превышен Заданный"|(
for /f "delims=" %%j in ('more') do @>nul chcp 866& cmd/v/c "echo.!date! !time:~0^,8! %%j")
)
findstr /i "Превышен Заданный Ответ"
Не удаётся найти указанный файл
Answer the question
In order to leave comments, you need to log in
I changed it a little, as it seemed to me correct - it should display the date / time in the log when the node is unavailable.
@echo off
set "iptoping=127.0.0.1"
set "pdir=C:\pinglog"
echo Пингуем %iptoping% пакетами по 5000 байт с выводом в %pdir%\ping_%iptoping%.log. Для завершения закройте окно.
1>nul 2>&1 md %pdir%
>"%pdir%\ping_%iptoping%.log" (
for /l %%i in () do (
for /f "delims=" %%a in ('ping -l 5000 -n 1 %iptoping% ^| findstr "Превышен Заданный Ответ" ') do echo.%date% %time:~0,8% %%a
)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question