标题: for循环内无法goto么,请帮忙看看
[打印本页]
作者: edeed
时间: 2007-2-28 06:38
标题: for循环内无法goto么,请帮忙看看
type tnsnames.ora | find "description" > temp1.tmp
for /f "tokens=1" %%i in (temp1.tmp) do (
echo ********************************** begin check %%i ********************************** >> %result_file%
tnsping %%i > temp2.tmp
if errorlevel 1 set tns_name=%%i && goto fail
sqlplus -s %usr%/%pwd%@%%i @%sql_file% >> %result_file%
echo %%i checked successful!
:fail
echo %tns_name%checked failful!
)
一旦其中一条有误,后面的就无法进行了,请问如何解决?
作者: vkill
时间: 2007-2-28 06:49
未知,for 内goto 老是这样,我改为 && || 这样写了
作者: everest79
时间: 2007-2-28 07:07
没看懂,那处出错
作者: edeed
时间: 2007-2-28 07:33
改成这样就可以了
type tnsnames.ora | find "description" > temp.tmp
for /f "tokens=1" %%i in (temp.tmp) do (
echo ********************************** begin check %%i ********************************** >> %result_file%
tnsping %%i > nul
if errorlevel 1 (echo %%i tnsping failing! && echo tnsping failing! >> %result_file%) else (
sqlplus -s %usr%/%pwd%@%%i @%sql_file% >> %result_file%
if errorlevel 1 (echo %%i sqlplus failing! && echo sqlplus failing! >> %result_file%) else (
echo %%i checked successful!
)
)
)