Batch Scripts

Batch Scripts

The sample scripts are not supported under any standard support program or service. The sample scripts are provided AS IS without warranty of any kind. I further disclaim all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall I, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if I or they have been advised of the possibility of such damages.

WGET to verify portal is up

@echo off
cls
setlocal enabledelayedexpansion
set pre=http://
set sufix=^.domain^.org/lawson/portal
set lbpsufix=^.domain^.root^.loc/lbp9

goto start

:start
del /Q h*.tmp.txt
del /Q index.html.*
del /Q out.txt

REM echo Checking bad URL
REM call :verportal2 heilawwiqasq
echo Checking Production Portal
call :verportal srtver001
echo Checking LBP Production
call :verportal1 server002
echo Checking Test Portal
call :verportal server003
echo Checking LBP Test
call :verportal1 server004
call :doublecheck
goto end

:verportal
<path>\wget %pre%%1%sufix% 1>nul 2>"%1.tmp.txt"
find /c "connected" "%1.tmp.txt" > NULL
if %errorlevel% equ 1 goto notthere
echo    Success %pre%%1%sufix% page shows connected.
goto end

:verportal1
<path>\wget %pre%%1%lbpsufix% 1>nul 2>"%1.tmp.txt"
set result=("type "%1.tmp.txt" | @find /i "connecting" | @find /i "connected"")
find /c "connected" "%1.tmp.txt" > NULL
if %errorlevel% equ 1 goto notthere
echo    Success %pre%%1%lbpsufix% page shows connected.
goto end

:notthere
echo.
echo ------- FAILURE reaching page!!!!
echo.
goto end

:doublecheck
echo.
echo Checks to see if 200 OK was received ^| 1 = was received
for /r %%B in ("h*.tmp.txt") do (@find /c "200 OK" %%B) >> out.txt
type out.txt
goto end

:end
endlocal
exit /B


Verify Checksum Batch

@ECHO off
TITLE Verify MD5 Checksum
if [%1]==[] GOTO useage
if [%2]==[] GOTO useage
if [%3]==[] (SET COMPTYPE=-md5) ELSE (SET COMPTYPE=%3)
REM requires Microsoft's File Checksum Integrity Verifier (FCIV) utility
SETLOCAL EnableDelayedExpansion
REM Put FCIV in this batch file's path
SET path=%path%;c:\gmTools\FCIV
SET FILENAME=%1
SET MD5TEST=%2
FCIV %COMPTYPE% %FILENAME% | findstr /B /C:"%MD5TEST%" >tmpfile
SET /p MD5VAR= <tmpfile
FOR /F "usebackq tokens=1" %%M IN (tmpfile) DO (@set MD5VAR2=%%M)
IF "%MD5TEST%" EQU "%MD5VAR2%" (GOTO:match) ELSE (GOTO:FAIL)
DEL tmpfile
GOTO:end

:match
@ECHO.  
@ECHO     Match: safe to use.
@ECHO.
GOTO:end    

:fail
@ECHO
@ECHO     Fail: unsafe to use or wrong encoding checked MD5 vs. SHA1.
@ECHO.
GOTO:end

:useage
@ECHO Syntax:
@ECHO        md5.cmd FullFilePath MD5Signature [-sha1 ^| -md5]
PAUSE
GOTO:end

:end
PAUSE
CLS
EXIT /B

No comments:

Post a Comment

Reflecting on Service

I was US Army Airborne Field Artillery - Target Acquisition. I never was in combat, so I don't think of myself as a veteran, but I do th...