中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-05 23:02
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [原创]*****IP和整数互相转换***** 查看 622 回复 2
楼 主 [原创]*****IP和整数互相转换***** 发表于 2007-09-25 16:56 ·  中国 北京 电信
银牌会员
★★★
积分 2,098
发帖 566
注册 2007-09-11 07:27
18年会员
UID 97070
性别 男
状态 离线
@echo off
::::::::::::::::::::::::::IP And Integer {s11ss 2007-9-25}::::::::::::::::::::::::::
set result=
if "%1" equ "/1" goto :ip2int
if "%1" equ "/2" goto :int2ip
echo Please input a parameter, /1 or /2 .
goto :e
:ip2int
echo Please input an IP,like 127.0.0.1:
set/p ip=
for /f "delims=. tokens=1-4" %%a in ('echo %ip%') do set/a result+=%%a*256*256*256+%%b*256*256+%%c*256+%%d
goto :e
:int2ip
echo Please input an Integer,like 2130706433:
set/p int=
set/a quotient=%int%
:c
set/a remainder=%quotient%%%256
set/a quotient=%quotient%/256
if "%result%" equ "" (set result=%remainder%) else (set result=%remainder%.%result%)
if not %quotient% equ 0 goto :c
goto :e
:e
echo.
echo.%result%
echo Press Any Key To Exit...
pause>nul
本帖最近评分记录 (共 1 条) 点击查看详情
评分人分数时间
knoppix7 +4 2007-09-25 18:57
2 发表于 2007-09-25 18:57 ·  中国 北京 海淀区 联通
银牌会员
★★★
积分 1,287
发帖 634
注册 2007-05-02 15:06
19年会员
UID 87277
性别 男
来自 cmd.exe
状态 离线
。。。。每天都有原创。佩服..
3 发表于 2007-09-25 19:56 ·  中国 甘肃 天水 秦州区 电信
金牌会员
★★★★
积分 4,103
发帖 1,744
注册 2006-01-20 13:00
20年会员
UID 49241
性别 男
来自 甘肃.临泽
状态 离线
应该是把 ip 转换为 “10进制” 数吧?
论坛跳转: