ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 写了各循环替换TNS文件的BAT脚本

写了各循环替换TNS文件的BAT脚本

原创 Linux操作系统 作者:darren__chan 时间:2014-11-09 19:39:43 0 删除 编辑

第一次写BAT,不喜勿喷!
写得比较小白!



@ECHO off
COLOR 6
TITLE TNS 切换程序 by darren
MODE CON: COLS=110 LINES=40


:begin
ECHO -----------------------------------------------------------------------------------
ECHO                 环境1                                             环境2
ECHO TNS 1.tnsnames TNS 1.ORA ---- TNS 1         TNS 6.tnsnames TNS 6.ORA ---- TNS 6
ECHO -----------------------------------------------------------------------------------
ECHO TNS 2.tnsnames TNS 2.ORA---- TNS 2           TNS 7.tnsnames TNS 7.ORA---- TNS 7
ECHO -----------------------------------------------------------------------------------
ECHO TNS 3.tnsnames TNS 3.ORA ---- TNS 3           TNS 8.tnsnames TNS 8.ORA ---- TNS 8  
ECHO -----------------------------------------------------------------------------------
ECHO TNS 4.tnsnames TNS 4.ORA ---- TNS 4          TNS 9.tnsnames TNS 9.ORA ---- TNS 9
ECHO -----------------------------------------------------------------------------------
ECHO TNS 5.tnsnames TNS 5.ORA ---- TNS 5           TNS 10.tnsnames TNS 10.ORA ---- TNS 10
ECHO -----------------------------------------------------------------------------------
ECHO 查看当前当前TNS设置:-----------------------v------------------------------------!!!
ECHO 查看命令对照表:----------------------------b------------------------------------!!!
ECHO 退出请输入:--------------------------------q------------------------------------!!!






rem XCOPY C:\AUTOEXEC.BAT D:\  
  


echo.                                                                                       
echo.
echo.


echo =======================================================================================
set localtns=D:\app\Administrator\product\11.2.0\client_1\network\admin\tnsnames.ora
if exist "%localtns%" ( echo 本地TNS路径为: "%localtns%" ) else echo 本地找不到"%localtns%" ,请查看是否安装oracle客户端或重新设置TNS路径!
echo =======================================================================================


echo.
:input
set  TheTNS=null
set /a number=number+1  
echo #########################################第 %number% 次输入####################################################
echo 请输入数字0-10选择TNS,字母命令请参照对照表,查看命令对照表请按‘b’
set /p TheTNS=请输入序号:        


echo 您输入的序号为:%TheTNS% 
rem if %TheTNS%=="1" goto tns1




if "%TheTNS%"=="1" (goto tns1)
if "%TheTNS%"=="2" (goto tns2)
if "%TheTNS%"=="3" (goto tns3)
if "%TheTNS%"=="4" (goto tns4)
if "%TheTNS%"=="5" (goto tns5)
if "%TheTNS%"=="6" (goto tns6)
if "%TheTNS%"=="7" (goto tns7)
if "%TheTNS%"=="8" (goto tns8)
if "%TheTNS%"=="9" (goto tns9)
if "%TheTNS%"=="10" (goto tns10)
if "%TheTNS%"=="q" (goto quit)
if "%TheTNS%"== "b" (goto begin)
if "%TheTNS%" LSS "1" (goto error)
if "%TheTNS%" GEQ "11" (goto error)
if "%TheTNS%"== null (goto error)






rem for %%i in (1 2 3 4 5 6 7 8 9 10) do echo tns%%i
 
echo ----------------------------------
echo ----------------------------------
echo ----------------------------------




:tns1
set tns=tnsnames TNS 1.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% --地税生产 TNS 1
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out




:tns2
set tns=tnsnames TNS 2.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% --地税预生产 TNS 2
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out




:tns3
set tns=tnsnames TNS 3.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% --地税功能 TNS 3
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out




:tns4
set tns=tnsnames TNS 4.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% --地税采集 TNS 4
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out






:tns5
set tns=tnsnames TNS 5.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% ----地税培训 TNS 5
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out








:tns6
set tns=tnsnames TNS 6.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% --国税生产 TNS 6
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out








:tns7
set tns=tnsnames TNS 7.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% -- TNS 7
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out






:tns8
set tns=tnsnames TNS 8.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% --国税功能 TNS 8
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out




:tns9
set tns=tnsnames TNS 9.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% --国税采集 TNS 9
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!!未替换!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out




:tns10
set tns=tnsnames TNS 10.ORA
echo ------------------------------------
echo 您当前选择的TNS为:%tns% --国税培训 TNS 10
echo ------------------------------------
set /p choice=请选择(y.执行 n.跳过):
if "%choice%"=="y" goto do
if "%choice%"=="n" echo 我想重新选择TNS!!!!!!! & goto out
if not "%choice%"=="y" if not "%choice%"=="n" echo 大哥,yes or no!!未替换!!!!! & goto out
:do
if not exist "%tns%" ( msg * "        未找到要复制的源文件" & echo 此次替换失败Failed!!!) else goto next
:next
if exist "%localtns%" (xcopy /e /y "%tns%"  "%localtns%" ) else  msg * "未找到要本地"%localtns%",请检查路径是否设置错误或是否已安装oracle客户端" 此次替换失败Failed!!!
goto out






:error
echo.
echo ------------------------------------
echo 错误:您输入的序号不存在,请重新输入
echo ------------------------------------
echo.
goto input 


:out
echo.
echo ------------------------------------------------------------------------
echo 重新输入序号进行更换TNS,查看命令对照表请按‘b’,查看当前当前TNS设置请按‘v’
echo -------------------------------------------------------------------------
echo.
goto input 






for /f %%a in ('type 1.txt') do echo %%a








:quit
echo 按任意键结束 自动关闭.bat
pause;



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29863023/viewspace-1326388/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: impdp query 导入
请登录后发表评论 登录
全部评论
一思尚存,此志不懈

注册时间:2014-09-09

  • 博文量
    210
  • 访问量
    1344180