TNSPING Multiple hosts
Posted: 29 Aug 2018 13:20
im trying to create a .bat to check multiple hosts, the code below doent work and idk why. please help me =)
@echo off
set fnm=c:\scripts\databases.txt
set lnm=c:\scripts\results.txt
if exist %fnm% goto Label1
echo.
echo Cannot find %fnm%
echo.
Pause
goto :eof
:Label1
echo Ping Test on %date% at %time% > %lnm%
echo ================================================= >> %lnm%
echo.
for /f %%i in (%fnm%) do call :Sub %%i
echo.
echo ================================================= >> %lnm%
echo Ping Test ENDED on %date% at %time% >> %lnm%
echo ... now exiting
goto :eof
:Sub
echo Testing %1
set state=OK
tnsping 1 %1
if errorlevel 1 set state=Down
echo %1 is %state% >> %lnm%
@echo off
set fnm=c:\scripts\databases.txt
set lnm=c:\scripts\results.txt
if exist %fnm% goto Label1
echo.
echo Cannot find %fnm%
echo.
Pause
goto :eof
:Label1
echo Ping Test on %date% at %time% > %lnm%
echo ================================================= >> %lnm%
echo.
for /f %%i in (%fnm%) do call :Sub %%i
echo.
echo ================================================= >> %lnm%
echo Ping Test ENDED on %date% at %time% >> %lnm%
echo ... now exiting
goto :eof
:Sub
echo Testing %1
set state=OK
tnsping 1 %1
if errorlevel 1 set state=Down
echo %1 is %state% >> %lnm%