Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 增强脚本ping批处理_Batch File_Logging_Ping - Fatal编程技术网

Batch file 增强脚本ping批处理

Batch file 增强脚本ping批处理,batch-file,logging,ping,Batch File,Logging,Ping,我为在我的公司测试本地网络制作了一个脚本。它能工作,但不是我想要的 如果正常,它将执行1次ping,测试时间(>=30ms)将执行另一次ping。所以它在我的循环中有两个ping 如果ok log仅当>=30ms,如果nok log,我想要1 ping 如何增强此脚本 set /p IP="Saisir une IP : " :loop ping.exe -n 1 %IP% | find "TTL" > NUL if %errorlevel% == 0 for /f "tokens=7 d

我为在我的公司测试本地网络制作了一个脚本。它能工作,但不是我想要的

如果正常,它将执行1次ping,测试时间(>=30ms)将执行另一次ping。所以它在我的循环中有两个ping

如果ok log仅当>=30ms,如果nok log,我想要1 ping

如何增强此脚本

set /p IP="Saisir une IP : "
:loop
ping.exe -n 1 %IP% | find "TTL" > NUL
if %errorlevel% == 0 for /f "tokens=7 delims==+<+ " %%i in ('ping.exe -n 1 %IP% ^| findstr /i /c:"temps"') do if %IP% GEQ 30 echo "%date% %time:~,8% ms=%%i" >> log_%IP%.txt
if %errorlevel% == 1 echo "%date% %time:~,8% Ne repond pas" >> log_%IP%.txt
timeout /t 1 > NUL
goto loop
set/p IP=“Saisir une IP:”
:循环
ping.exe-n 1%IP%|查找“TTL”>NUL
如果%errorlevel%==0表示/f“令牌=7 delims==+Essayeça:

@echo off
set /p IP="Saisir une IP : "
:loop
for /f "tokens=6 delims==ms" %%a in ('ping.exe -n 1 %IP% ^| find "TTL"') do if %%a GEQ 30 echo "%date% %time:~,8% ms=%%a"
timeout /t 1 > NUL
goto:loop

敬礼,谢谢你的帮助

Si Ping>30ms浮雕原木,例如:

Test Ping en cours vers 8.8.8.8 
Commencer le 29/06/2017, 16:02:26 

=============================== 
= NE PAS FERMER CETTE FENETRE = 
=============================== 

"29/06/2017 16:02:27 ms=70" 
"29/06/2017 16:02:28 ms=94" 
艾斯平高,特例:

Test Ping en cours vers 192.192.192.192 
Commencer le 29/06/2017, 16:05:58 

=============================== 
= NE PAS FERMER CETTE FENETRE = 
=============================== 

"29/06/2017 16:06:02 Ne repond pas" 
"29/06/2017 16:06:06 Ne repond pas" 
Si ping OK alors rien dans le log

至@Banee Ishaque K

当然可以,这是整个剧本

@echo off
set /p IP="Type an IP : "
cls
(echo Test Ping in progress to %IP%
echo Start at %date%, %time:~,8%
echo.
echo ============================
echo = DON T CLOSE THIS WINDOWS =
echo ============================
echo.) >> log_%IP%.txt | type log_%IP%.txt
:loop
ping.exe -n 1 %IP% | find "TTL" > NUL
if %errorlevel% == 0 for /f "tokens=7 delims==+<+ " %%i in ('ping.exe -n 1 %IP% ^| findstr /i /c:"time"') do if %IP% GEQ 30 echo "%date% %time:~,8% ms=%%i" >> log_%IP%.txt
if %errorlevel% == 1 echo "%date% %time:~,8% Not working" >> log_%IP%.txt
timeout /t 1 > NUL
goto loop
@echo关闭
set/p IP=“键入IP:”
cls
(正在对%IP%进行回声测试Ping)
回显开始时间为%date%,%time:~,8%
回声。
回音============================
echo=不要关闭此窗口=
回音============================
echo.)>>日志%IP%.txt |键入日志%IP%.txt
:循环
ping.exe-n 1%IP%|查找“TTL”>NUL

如果%errorlevel%==0表示/f“tokens=7 delims===+感谢大家的贡献,我会回应自己

以下是完整的脚本:

@echo off
:: Ce script permet de tester le réseau local d'un client

:: Déclaration de la variable IP, à saisir en exécutant le script
set /p IP="Saisir une IP : "
set /p MS="Valeur de test (en ms) : "

cls

:: Bloque de commentaire dans un fichier log et affichage à l'écran
(echo Test Ping en cours vers %IP%
echo Commencer le %date%, %time:~,8%
echo.
echo ===============================
echo = NE PAS FERMER CETTE FENETRE =
echo ===============================
echo.) >> log_%IP%.txt | type log_%IP%.txt

:: Boucle infini : commande ping avec 1 paquet
:: Si erreur le script log
:: Si pas d'erreur le script log les résultats supérieur ou égal à la valeur de test en ms
:: La boucle se relance toutes les secondes
:loop
for /f "tokens=1,7 delims==+<+ " %%a in ('ping.exe -n 1 %IP% ^| findstr /i /c:"temps"^|^| echo "Ne Repond Pas"') do (
 if "%%b" == "" (
  echo "%date% %time:~,8% Ne repond pas" >> log_%IP%.txt
 ) ELSE (
  if %%b GEQ %MS% (
   echo "%date% %time:~,8% ms=%%b" >> log_%IP%.txt
  )
 )
)
timeout /t 1 > NUL
goto loop
@echo关闭
::Ce脚本测试程序本地客户端
::变量IP的声明,在脚本中使用
set/p IP=“Saisir une IP:”
set/p MS=“Valeur de test(en-MS):”
cls
当前位置:日志和附件中的注释块
(回声测试过程中的平均值%IP%
回音开始符le%日期%,%时间:~,8%
回声。
回音===============================
echo=NE PAS FERMER CETTE FENETRE=
回音===============================
echo.)>>日志%IP%.txt |键入日志%IP%.txt
::花束内胎:一件一件
::Si erreur le脚本日志
::这是一份脚本日志,记录了测试过程中的测试结果
当前位置:La boucle se relance Toues les secondes
:循环

对于/f“tokens=1,7 delims==+你会用英语吗?