批处理中的FOR和set问题
以下是我一个、bat文件里面的内容。大家看看,我的FOR语句和SET之间是不是有什么不对。请给我指点一下,谢谢。setoa1=127setoa2=64setoa3=32s...
以下是我一个、bat文件里面的内容。大家看看,我的FOR 语句和SET之间是不是有什么不对。请给我指点一下,谢谢。
set oa1=127
set oa2=64
set oa3=32
set oa4=16
set oa5=8
set oa6=4
set oa7=2
set oa8=1
set spl=ipl.txt
set spm=ipm.txt
set b2=srm\b.txt
echo 您的最小IP为?
set /p ipl=
echo 您的最大IP为?
set /p ipm=
echo %ipl% >> %spl%
echo %ipm% >> %spm%
for /f "tokens=1,2,3,4 delism=."%%i (`spl%`) do set il1=%%i il2=%%j il3=%%k il4=%%l
for /f "skip=%il1% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set l1=%%i l2=%%j l3=%%k l4=%%l l5=%%m l6=%%n l7=%%o l8=%%p
for /f "skip=%il2% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set l9=%%i l10=%%j l11=%%k l12=%%l l13=%%m l14=%%n l15=%%o l16=%%p
for /f "skip=%il3% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set l17=%%i l18=%%j l19=%%k l20=%%l l21=%%m l22=%%n l23=%%o l24=%%p
for /f "skip=%il4% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set l25=%%i l26=%%j l27=%%k l28=%%l l29=%%m l30=%%n l31=%%o l32=%%p
for /f "tokens=1,2,3,4 delism=."%%i (`spm`) do set im1=%%i im2=%%j im3=%%k im4=%%l
for /f "skip=%im1% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set m1=%%i m2=%%j m3=%%k m4=%%l m5=%%m m6=%%n m7=%%o m8=%%p
for /f "skip=%im2% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set m9=%%i m10=%%j m11=%%k m12=%%l m13=%%m m14=%%n m15=%%o m16=%%p
for /f "skip=%im3% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set m17=%%i m18=%%j m19=%%k m20=%%l m21=%%m m22=%%n m23=%%o m24=%%p
for /f "skip=%im4% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set m25=%%i m26=%%j m27=%%k m28=%%l m29=%%m m30=%%n m31=%%o m32=%%p
:n1
if %l1% neq %m1% goto o0
if %l2% neq %m2% goto o1
if %l3% neq %m3% goto o2
if %l4% neq %m4% goto o3
:n2
if %l9% neq %m9% goto o8
.
if %l16% neq %m16% goto o15
:n3
if %l17% neq %m17% goto o16
.
if %l24% neq %m24% goto o23
:n4
if %l25% neq %m25% goto o24
.
if %l32% neq %m32% goto o31
goto o32
:e1
:o0
echo ou
:o1
set /a oa=%oa1%
goto t1
:o2
set /a oa=%oa1%+%oa2%
goto t1
:o3
set /a oa=%oa1%+%oa2%+%oa3%
goto t1
:o4
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%
goto t1
:o5
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%
goto t1
:o6
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%
goto t1
:o7
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%+%oa7%
goto t1
:o8
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%+%oa7%+%oa8%
goto t1
:e2
:o0
echo ou
:o9
set /a ob=%oa1%
goto t2
:o10
set /a ob=%oa1%+%oa2%
goto t2
:o11
set /a ob=%oa1%+%oa2%+%oa3%
goto t2
:o12
set /a ob=%oa1%+%oa2%+%oa3%+%oa4%
goto t2
.
.
.
:o31
set /a od=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%+%oa7%
goto t4
:o32
set /a od=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%+%oa7%+%oa8%
goto t4
:t1
goto n2
:t2
goto n3
:t3
goto n4
:t4
echo netmask:%oa%.%ob%.%oc%.%od% >>sn.txt
pause 展开
set oa1=127
set oa2=64
set oa3=32
set oa4=16
set oa5=8
set oa6=4
set oa7=2
set oa8=1
set spl=ipl.txt
set spm=ipm.txt
set b2=srm\b.txt
echo 您的最小IP为?
set /p ipl=
echo 您的最大IP为?
set /p ipm=
echo %ipl% >> %spl%
echo %ipm% >> %spm%
for /f "tokens=1,2,3,4 delism=."%%i (`spl%`) do set il1=%%i il2=%%j il3=%%k il4=%%l
for /f "skip=%il1% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set l1=%%i l2=%%j l3=%%k l4=%%l l5=%%m l6=%%n l7=%%o l8=%%p
for /f "skip=%il2% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set l9=%%i l10=%%j l11=%%k l12=%%l l13=%%m l14=%%n l15=%%o l16=%%p
for /f "skip=%il3% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set l17=%%i l18=%%j l19=%%k l20=%%l l21=%%m l22=%%n l23=%%o l24=%%p
for /f "skip=%il4% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set l25=%%i l26=%%j l27=%%k l28=%%l l29=%%m l30=%%n l31=%%o l32=%%p
for /f "tokens=1,2,3,4 delism=."%%i (`spm`) do set im1=%%i im2=%%j im3=%%k im4=%%l
for /f "skip=%im1% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set m1=%%i m2=%%j m3=%%k m4=%%l m5=%%m m6=%%n m7=%%o m8=%%p
for /f "skip=%im2% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set m9=%%i m10=%%j m11=%%k m12=%%l m13=%%m m14=%%n m15=%%o m16=%%p
for /f "skip=%im3% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set m17=%%i m18=%%j m19=%%k m20=%%l m21=%%m m22=%%n m23=%%o m24=%%p
for /f "skip=%im4% tokens=1,2,3,4,5,6,7,8" %%i (`b2`) do set m25=%%i m26=%%j m27=%%k m28=%%l m29=%%m m30=%%n m31=%%o m32=%%p
:n1
if %l1% neq %m1% goto o0
if %l2% neq %m2% goto o1
if %l3% neq %m3% goto o2
if %l4% neq %m4% goto o3
:n2
if %l9% neq %m9% goto o8
.
if %l16% neq %m16% goto o15
:n3
if %l17% neq %m17% goto o16
.
if %l24% neq %m24% goto o23
:n4
if %l25% neq %m25% goto o24
.
if %l32% neq %m32% goto o31
goto o32
:e1
:o0
echo ou
:o1
set /a oa=%oa1%
goto t1
:o2
set /a oa=%oa1%+%oa2%
goto t1
:o3
set /a oa=%oa1%+%oa2%+%oa3%
goto t1
:o4
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%
goto t1
:o5
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%
goto t1
:o6
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%
goto t1
:o7
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%+%oa7%
goto t1
:o8
set /a oa=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%+%oa7%+%oa8%
goto t1
:e2
:o0
echo ou
:o9
set /a ob=%oa1%
goto t2
:o10
set /a ob=%oa1%+%oa2%
goto t2
:o11
set /a ob=%oa1%+%oa2%+%oa3%
goto t2
:o12
set /a ob=%oa1%+%oa2%+%oa3%+%oa4%
goto t2
.
.
.
:o31
set /a od=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%+%oa7%
goto t4
:o32
set /a od=%oa1%+%oa2%+%oa3%+%oa4%+%oa5%+%oa6%+%oa7%+%oa8%
goto t4
:t1
goto n2
:t2
goto n3
:t3
goto n4
:t4
echo netmask:%oa%.%ob%.%oc%.%od% >>sn.txt
pause 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询