[关闭]
@cyysu 2017-10-12T10:18:38.000000Z 字数 2156 阅读 854

Bat-实战基础篇(三)

  • 时间:2017年10月12日
  • 作者:Kali
  • 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
  • 版本:4.0
  • 描述:批处理实战基础篇三,主要讲解tomcat下启动脚本,本文主要讲解version.bat这个脚本

Bat系列教程


项目实战

其目录下面的脚本文件如下,有些重复的内容,这里不做过多介绍,有遇到什么不会的内容可以查看Bat系列教程

下面我们一一来分析其里面的内容,为了避免文本过长,每个文件单独一篇文章讲解。

  1. # version.bat
  2. @echo off
  3. rem Licensed to the Apache Software Foundation (ASF) under one or more
  4. rem contributor license agreements. See the NOTICE file distributed with
  5. rem this work for additional information regarding copyright ownership.
  6. rem The ASF licenses this file to You under the Apache License, Version 2.0
  7. rem (the "License"); you may not use this file except in compliance with
  8. rem the License. You may obtain a copy of the License at
  9. rem
  10. rem http://www.apache.org/licenses/LICENSE-2.0
  11. rem
  12. rem Unless required by applicable law or agreed to in writing, software
  13. rem distributed under the License is distributed on an "AS IS" BASIS,
  14. rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. rem See the License for the specific language governing permissions and
  16. rem limitations under the License.
  17. rem ---------------------------------------------------------------------------
  18. rem Version script for the CATALINA Server
  19. rem ---------------------------------------------------------------------------
  20. setlocal
  21. rem Guess CATALINA_HOME if not defined
  22. :: 设置CURRENT_DIR为当前目录 %cd%指的是当前进入的目录
  23. set "CURRENT_DIR=%cd%"
  24. :: 如果CATALINA_HOME已经设置了 就跳转gotHome标签
  25. if not "%CATALINA_HOME%" == "" goto gotHome
  26. :: 如果没有的话,那么就设置为当前目录
  27. set "CATALINA_HOME=%CURRENT_DIR%"
  28. :: 如果存在catalina.bat,就跳转okHome标签
  29. if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
  30. cd ..
  31. set "CATALINA_HOME=%cd%"
  32. cd "%CURRENT_DIR%"
  33. :gotHome
  34. if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
  35. echo The CATALINA_HOME environment variable is not defined correctly
  36. echo This environment variable is needed to run this program
  37. goto end
  38. :okHome
  39. set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"
  40. rem Check that target executable exists
  41. if exist "%EXECUTABLE%" goto okExec
  42. echo Cannot find "%EXECUTABLE%"
  43. echo This file is needed to run this program
  44. goto end
  45. :okExec
  46. rem Get remaining unshifted command line arguments and save them in the
  47. set CMD_LINE_ARGS=
  48. :setArgs
  49. if ""%1""=="""" goto doneSetArgs
  50. :: 如果输入参数不为空 那么将参数进行移位操作
  51. set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  52. shift
  53. goto setArgs
  54. :doneSetArgs
  55. :: 调用其他脚本 传递的参数为 version %CMD_LINE_ARGS%
  56. call "%EXECUTABLE%" version %CMD_LINE_ARGS%
  57. :end

打赏

                    支付宝                                                         微信

微信与支付宝支付

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注