Friday, February 28, 2014

Make sure you're clear to change your password

The following script I use to verify that I am not logged in anywhere else before I change my domain password.

@echo off
set me=logon

for /F %%S in (myservers.txt) do (@echo %%S && @query session /SERVER:%%S | find "%me%")

  • Change `me` to your domain logon
  • create myservers.txt with a list of the servers you want to limit your search to, then save it in the same folder as this script.

Cheap Portal Monitor

Below is a script that I use to check that the portals are running and errors are not present. Sometime services lie!

@echo off
cls
SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
set pre=http://
set sufix=^.domain^.org/lawson/portal
set lbpsufix=^.domain^.root^.loc/lbp9
set lbisufix=^.domain^.root^.loc:9080/efs/
:: Inteded to have wget installed on host pc
set wgetpath=C:\wget\bin
:: intended to be run from USB drive
set locroot=%~dp0
rem <esc>[<attribute>;<foreground>;<background>m
set yellow=[1;33;40m
set cyan=[1;36;40m
set red=[1;31;40m
set normal=[0;32;40m

goto start

:start
cd %locroot%\scripts\Infor\
@del /Q h*.tmp.txt && @cls
@del /Q index.html.* && @cls
@del /Q out.*txt && @cls
@del /Q final.txt && @cls
@del /Q finalf.txt && @cls
@del /Q SSOServlet@_action* && @cls
@del /Q null && @cls
goto:flow

:flow
for %%M in (server1 server2) do call :verportal %%M
for %%N in (server3 server4) do call :verportal1 %%N
for %%O in (server5 server6) do call :verportal2 %%O
@cls
call :doublecheck
call :display
goto:EOF

:verportal
%wgetpath%\wget %pre%%1%sufix% 1>nul 2>"%1.tmp.txt"
find /c "connected" "%1.tmp.txt" >NULL
if %errorlevel% equ 1 goto notthere
goto:end

:verportal1
%wgetpath%\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
goto:end

:verportal2
%wgetpath%\wget %pre%%1%lbisufix% 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
goto:end

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

:doublecheck
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
for /r %%C in (out.txt) do (@type out.txt | @findstr /E /R /X ".*1$" >> final.txt)
for /r %%D in (out.txt) do (@type out.txt | @findstr /E /R /X ".*0$" >> finalf.txt)
goto:end

:display
for /F "delims=\ tokens=4,5" %%E in (final.txt) do @echo %cyan% %%E
for /F "delims=\ tokens=4,5" %%F in (finalf.txt) do @echo %red% %%F
goto:end

:end
@echo %normal%

:EOF
endlocal
exit /B
-

Output looks like:

Checks to see if 200 OK was received | 1 = was received
 server1.TMP.TXT: 1
 server2.TMP.TXT: 1
 server3.TMP.TXT: 1
 server4.TMP.TXT: 1
 server5.TMP.TXT: 1
 server6.TMP.TXT: 0

F:\scripts\Infor>

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...