My Opera is closing 1st of March

M.I.T = Multimedia IT dept.

Subscribe to RSS feed

check socket connection and reboot: socketNreboot.bat

, ,

@echo off

:: check if the socket can be established
SET SOCKETORNOT=
for /f "tokens=1 usebackq" %%A in (`perl checksocket.pl`) do (SET SOCKETORNOT=%%A)
if "%SOCKETORNOT%" == "NOTCONNECTED" goto REBOOTNOW
echo Network is alive...

:: start checking whether the connection is alive in netstat!!
SET WMSPORT=8080
netstat | find "localhost:%WMSPORT%" > checkwms.log
SET WMSON=
for /f "tokens=4" %%A in (checkwms.log) do (SET WMSON=%%A)
if not "%WMSON%" == "ESTABLISHED" goto DOWN
echo WMS keeps running...
goto EXIT

:DOWN
:: print out down time to error log and restart WMServer...
for /f "tokens=1-2 usebackq" %%A in (`date /T`) do (SET NOWDATE=%%A %%B)
for /f "tokens=1-2 usebackq" %%A in (`time /T`) do (SET NOWTIME=%%A %%B)
echo %NOWDATE% %NOWTIME% WMS connection restarts...>> checkwmserr.txt
sc stop WMServer
sc start WMServer
goto EXIT

:REBOOTNOW
:: print out reboot time to error log and restart Windows...
for /f "tokens=1-2 usebackq" %%A in (`date /T`) do (SET NOWDATE=%%A %%B)
for /f "tokens=1-2 usebackq" %%A in (`time /T`) do (SET NOWTIME=%%A %%B)
echo %NOWDATE% %NOWTIME% Windows reboots...>> checkwmserr.txt
shutdown -r
goto EXIT

:EXIT
echo exiting...
February 2014
M T W T F S S
January 2014March 2014
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28