@echo off

:: ops1.bat
::
:: scan customer subnets for responding smartbridges (802.11b radio) devices.
:: If device responds, record its RTS & fragmentation thresholds.
::
:: usage: ops1 [communityname]
:: (default communityname is public)
::
:: blame: shardy@@methownet.com
::
:: uses snmpget.exe from freeware ucd-snmp
:: and  tlist.exe from one of the reskits


setlocal

:: see AT76C510.mib for definitions

set  RTS=enterprises.410.1.2.1.4
set frag=enterprises.410.1.2.1.5

set cmty=public

if not %1.==. set cmty=%1
if exist ops.txt del ops.txt

for %%z in (21 22 23 24) do call :getOps %%z

if exist ops.txt type ops.txt
echo done
endlocal
goto :eof

 
:getOps
  echo [x.%1.y]
  if exist *.rts del *.rts
  if exist *.frag del *.frag
  echo rts
  for /l %%a in (2,1,253) do (
     start "rts:%%a" /min cmd /c "snmpget -Oqv -c %cmty% 10.0.%1.%%a  %RTS% >%%a.rts"
   )
  call :waitloop rts: 

  echo frag
  for /l %%a in (2,1,253) do (
   start "frag:%%a" /min cmd /c "snmpget -Oqv -c %cmty% 10.0.%1.%%a  %frag% >%%a.frag"
   )
  call :waitloop frag:

  for /f "tokens=3*" %%a in ('dir *.rts') do @if %%a==0 del %%b
  for /f "tokens=3*" %%a in ('dir *.frag') do @if %%a==0 del %%b
  for %%a in (*.rts) do (
    for /f "tokens=1,2 delims=." %%b in ("%%a") do (
      for /f %%d in (%%a) do for /f %%e in (%%b.frag) do (
        echo 10.0.%1.%%b	rts: %%d	frag: %%e >>ops.txt
        )
      )
    )
  if exist *.rts del *.rts
  if exist *.frag del *.frag
  goto :eof

:waitloop
  echo waiting...
  sleep.exe 5
  tlist |find "%1" >nul&&goto  waitloop
  goto :eof