这样做是不是想文件小些呢?还是别的作用?
下面是我几天前写的对纯真数据库搜索IP的批处理
不过太慢了 最后还是放弃了
@echo off&setlocal enabledelayedexpansion&color 1E
title IP地址查询
mode con: cols=55 lines=15
:start
cls
echo.&echo.
echo 请输入所要查询的IP
for %%a in (ip ipa aip bip cip ip1 ip2 ip3 ip4) do set %%a=
set /p ipa=
if not defined ipa exit
cls
for /f "tokens=1,2,3,4 delims=. " %%a in ('echo !ipa!') do (
set ip1=%%a
set ip2=%%b
set ip3=%%c
set ip4=%%d
)
if !ip1! GTR 255 goto start
if !ip2! GTR 255 goto start
if !ip3! GTR 255 goto start
if !ip4! GTR 255 goto start
set ip=!ipa!
set ip=!ip:.=\.!
for /f "tokens=1,2*" %%i in ('findstr "\<!ip!\>" ip.txt') do (
set aip=%%i
set bip=%%j
set cip=%%k
)
if "!cip!"=="" goto ip2
goto ok
:ip2
if "!ip4!"=="0" goto ip3
set /a ip4-=1
set ip=!ip1!.!ip2!.!ip3!.!ip4!
set ip=!ip:.=\.!
for /f "tokens=1,2*" %%i in ('findstr "\<!ip!\>" ip.txt') do (
set aip=%%i
set bip=%%j
set cip=%%k
)
if "!cip!"=="" goto ip2
goto ok
:ip3
if "!ip3!"=="0" if "!cip!"=="" goto ip4
set /a ip3-=1
set ip=!ip1!.!ip2!.!ip3!
set ip=!ip:.=\.!
for /f "tokens=1,2*" %%i in ('findstr "\<!ip!\>" ip.txt') do (
set aip=%%i
set bip=%%j
set cip=%%k
)
if "!cip!"=="" goto ip3
goto ok
:ip4
if "!ip2!"=="0" goto ip5
set /a ip3-=1
set ip=!ip1!.!ip2!
set ip=!ip:.=\.!
for /f "tokens=1,2*" %%i in ('findstr "\<!ip!\>" ip.txt') do (
set aip=%%i
set bip=%%j
set cip=%%k
)
if "!cip!"=="" goto ip4
goto ok
:ip5
set ip=!ip1!
set ip=!ip:.=\.!
for /f "tokens=1,2*" %%i in ('findstr "\<!ip!\>" ip.txt') do (
set aip=%%i
set bip=%%j
set cip=%%k
)
:ok
if "!cip!"=="" goto nip
echo 你查询的IP: !ipa!
echo 所属IP段: !aip!-!bip!
echo IP所在地: !cip!
pause
goto start
:nip
echo.&echo.
echo 你查询的IP: !ipa!
echo.
echo 很抱歉!没找到你要查询的IP
echo.
pause
goto start
回得这么快
Last edited by terse on 2007-11-12 at 02:35 AM ]