China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-09 03:12
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » What's wrong? View 1,193 Replies 9
Original Poster Posted 2008-06-24 12:46 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
I set up a CS server just for fun. Since mine is a dynamic IP, and adding SXE requires modifying the IP parameter, I made a P to do it:
@echo off
set /p lip=<lip.txt
del ips.asp 1>nul 2>&1
wget http://www.ip138.com/ips.asp 1>nul 2>&1
for /f "tokens=2 skip=2 delims=" %%i in ('find "您的IP地址是:" ips.asp') do set "ip=%%i"
del ips.asp 1>nul 2>&1
echo Last imported IP was: %lip%
echo Current public IP is: %ip%
if %lip%==%ip% echo The two are the same!
set /p cf=Need to import it? Press Y to confirm, anything else to quit:
if %cf%=="y" goto :cip || goto :eof
:cip
echo.
echo Importing, please wait...
U82GB.vbs "server.cfg"
for /f "delims=" %%j in (server.cfg) do (
echo.%%j | findstr/i "__sxei_internal_ip">nul && echo __sxei_internal_ip %ip%||echo %%j
)>>sv.tmp
move sv.tmp server.cfg
GB2U8.vbs "server.cfg"
echo.%ip%>lip.txt
cls&echo Successfully imported %ip%!
pause


What I wanted was to import only when "Y" is entered, but right now only pressing Enter directly exits; pressing any key will import it. So where exactly is the mistake?
Floor 2 Posted 2008-06-24 12:48 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 65
Posts 29
Joined 2008-03-24 12:17
18-year member
UID 113853
Gender Male
Status Offline
if /i “%cf%”=="y" goto :cip || goto :eof


Try adding quotes around %cf% in this line, and I also suggest adding /I so it won't be case-sensitive...
Floor 3 Posted 2008-06-24 12:53 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
Thanks! Still doesn't work
Floor 4 Posted 2008-06-24 13:18 ·  中国 浙江 温州 电信
初级用户
★★
Credits 158
Posts 89
Joined 2007-04-25 08:06
19-year member
UID 86402
Gender Male
Status Offline
Floor 5 Posted 2008-06-24 13:22 ·  中国 浙江 温州 电信
初级用户
★★
Credits 158
Posts 89
Joined 2007-04-25 08:06
19-year member
UID 86402
Gender Male
Status Offline
Floor 6 Posted 2008-06-24 13:53 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
Originally posted by kgdetg1127 at 2008-6-24 01:22 PM:
if not %cf%==y goto :eof ||goto :cip


It can't jump to cip
Import failed
Floor 7 Posted 2008-06-24 15:05 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 65
Posts 29
Joined 2008-03-24 12:17
18-year member
UID 113853
Gender Male
Status Offline
I think
if /i “%cf%”=="y" goto :cip || goto :eof

this way of writing is itself problematic. Whether the input is correct or not, the goto :eof after || will never get executed.
I suggest changing those lines like this:

if /i "%cf%"=="y" goto :cip
goto :eof
:cip

This way, when the input is Y it jumps to clip, otherwise it executes the next line and automatically jumps to eof
Floor 8 Posted 2008-06-24 15:10 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
if /i "%cf%" neq "y" goto :eof
echo.
echo Importing, please wait...
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
radem +2 2008-06-25 13:02
批处理之家新域名:www.bathome.net
Floor 9 Posted 2008-06-24 21:48 ·  中国 福建 三明 电信
中级用户
★★
Credits 458
Posts 211
Joined 2006-07-26 19:42
20-year member
UID 59307
Status Offline
if %cf%=="y" goto :cip || goto :eof
:cip

Change it to:
if %cf%=="y" goto :cip else goto :eof
:cip

or
if not "%cf%"=="y" goto :eof
┌───────┐
├→学习→实践→┤
└───────┘
Floor 10 Posted 2008-06-25 18:46 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
<!Originally posted by zw19750516 at 2008-6-24 03:10 PM:
if /i "%cf%" neq "y" goto :eof
echo.
echo Importing, please wait...

That's it! Thanks ]>
Forum Jump: