2012年06月27日

PINGを実行し正常or異常を判定し結果を返すバッチファイル。

■ファイル名
ping.bat
@echo off
echo 192.168.0.1にPINGを実行します。

ping 192.168.0.1 -n 4 
@if errorlevel 1 GOTO test1_NG
@if errorlevel 0 GOTO test1_OK
:test1_OK
echo.
echo ***************
echo テスト①正常終了
echo ***************
echo.
pause
GOTO END

:test1_NG
echo.
echo ***************
echo テスト①異常終了
echo ***************
echo.
pause
GOTO END

:END


■実行結果
■正常な場合
192.168.0.1にPINGを実行します。

Pinging 192.168.0.1 with 32 bytes of data:

Reply from 192.168.0.1: bytes=32 time<1ms TTL=128
Reply from 192.168.0.1: bytes=32 time<1ms TTL=128
Reply from 192.168.0.1: bytes=32 time<1ms TTL=128
Reply from 192.168.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

***************
テスト①正常終了
***************

続行するには何かキーを押してください . . .


■異常な場合
192.168.0.1にPINGを実行します。

Pinging 192.168.0.1 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.0.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

***************
テスト①異常終了
***************

続行するには何かキーを押してください . . .




the_mercury_rising at 21:08│Comments(0)TrackBack(0)

トラックバックURL

この記事にコメントする

名前:
URL:
  情報を記憶: 評価: 顔