鱼C论坛

 找回密码
 立即注册

【待测试】PING命令脚本一行输出

已有 328 次阅读2014-10-29 12:13 |个人分类:Study Script

NND,用了一上午,水平太菜了

@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in (WKT.txt)do (set ipaddr= %%i
for /f "delims=" %%m in ('ping -n 1 !ipaddr!^|find "TTL" ^>ping.txt ^&^& echo ping !

ipaddr! 1 ^|^| echo ping !ipaddr! 0')do (
set str_ping=!date!!time! %%m)
echo !str_ping!
)

【新】
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1,2,4 delims= " %%i in (WKT.txt)do (set station= %%i
set contractor=%%j
set ipaddr=%%k
for /f "delims=" %%m in ('ping -n 1 !ipaddr!^|find "TTL" ^&^& echo ping !ipaddr! 1 ^|^| echo ping !ipaddr! 0')do (
set str_ping=!date!!time! !station!-!contractor!
set str_ping=!str_ping! %%m
echo !str_ping!>>ping.txt)
)
pause

【update】@2014-11-16

@echo off
set /p filename=please input the current contractor and station(e.g.816B-WKT):
echo your input is:%filename%
echo now the ping tesing is in progress,please wait..........................
setlocal enabledelayedexpansion
for /f "tokens=1,2,3,4 delims= " %%i in (gateway.txt)do (set station= %%i
set contractor=%%j
set description=%%k
set ipaddr=%%l
for /f "delims=" %%m in ('ping -n 1 !ipaddr!^|find "TTL"  ^&^& echo !ipaddr! 1 ^|^| echo ping !ipaddr! 0')do (
set str_ping=!date!!time! !station!-!contractor!-!description! %%m
echo !str_ping!>>!filename!.txt)
)
echo.
echo ping testing is completed,please check the result
echo.
pause

【update】2014-11-17

@echo off
:restart
set /p filename=please input the current contractor and station(e.g.816B-WKT):
echo your input is:%filename% (Y/N?)
set /p selection=
if %selection%==Y goto continue
if %selection%==N goto restart
:continue
echo now the ping tesing is in progress,please wait..........................
setlocal enabledelayedexpansion
for /f "tokens=1,2,3,4 delims= " %%i in (gateway.txt)do (set station= %%i
set contractor=%%j
set description=%%k
set ipaddr=%%l
for /f "delims=" %%m in ('ping -n 4 !ipaddr!^|find "TTL"  ^&^& echo ping !ipaddr! 1 ^|^| echo ping !ipaddr! 0')do (
set str_ping=!date!!time! !station!-!contractor!-!description! %%m
echo !str_ping!>>!filename!.txt)
)
echo.
echo ping testing is completed,please check the result in current directory with filename !filename!.txt
echo.
pause


PING交换机网关地址批处理
——————————————————————————————————
@echo off
echo change ip address (Y/N?)
set /p selection=
if %selection%==Y goto ipdizhi
if %selection%==N goto restart
:ipdizhi
echo please input the ip address:
set /p ipdizhi=
echo ip address is: %ipdizhi% (Y/N?)
set /p selection=
if %selection%==Y goto submask
if %selection%==N goto ipdizhi
:submask
echo please input the sub mask:
set /p submask=
echo sub mask is: %submask% (Y/N?)
set /p selection=
if %selection%==Y goto gateway
if %selection%==N goto submask
:gateway
echo please input the gateway address:
set /p gateway=
echo gateway address is: %gateway% (Y/N?)
set /p selection=
if %selection%==Y goto setip
if %selection%==N goto gateway
:setip
echo setting ip address is in progress......
netsh interface ipv4 set address "本地连接" static %ipdizhi% %submask% %gateway%
if %errorlevel%==0 (netsh interface ipv4  show ip) else (echo ---------------------Setting Error-----------------&echo erro code:%ERRORLEVEL%&echo ---------------------------------------------------) 
echo continue the following dcntesting (Y/N?)
set /p selection=
if %selection%==Y goto restart
if %selection%==N goto end
:restart
echo.
set /p filename=please input the current contractor and station(e.g.816B-WKT):
echo your input is:%filename% (Y/N?)
set /p selection=
if %selection%==Y goto continue
if %selection%==N goto restart
:continue
echo now the ping tesing is in progress,please wait..........................
setlocal enabledelayedexpansion
for /f "tokens=1,2,3,4 delims= " %%i in (gateway.txt)do (set station= %%i
set contractor=%%j
set description=%%k
set ipaddr=%%l
for /f "delims=" %%m in ('ping -n 4 !ipaddr!^|find "TTL"  ^&^& echo ping !ipaddr! 1 ^|^| echo ping !ipaddr! 0')do (
set str_ping=!date!!time! !station!-!contractor!-!description! %%m
echo !str_ping!>>!filename!.txt)
)
echo.
echo ping testing is completed,please check the result in current directory with filename !filename!.txt
echo.
:end
pause



路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-19 10:11

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

返回顶部