@cyysu
2017-10-12T10:18:38.000000Z
字数 2156
阅读 854
- 时间:2017年10月12日
- 作者:Kali
- 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
- 版本:4.0
- 描述:批处理实战基础篇三,主要讲解tomcat下启动脚本,本文主要讲解version.bat这个脚本
Bat系列教程
其目录下面的脚本文件如下,有些重复的内容,这里不做过多介绍,有遇到什么不会的内容可以查看Bat系列教程
下面我们一一来分析其里面的内容,为了避免文本过长,每个文件单独一篇文章讲解。
# version.bat
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ---------------------------------------------------------------------------
rem Version script for the CATALINA Server
rem ---------------------------------------------------------------------------
setlocal
rem Guess CATALINA_HOME if not defined
:: 设置CURRENT_DIR为当前目录 %cd%指的是当前进入的目录
set "CURRENT_DIR=%cd%"
:: 如果CATALINA_HOME已经设置了 就跳转gotHome标签
if not "%CATALINA_HOME%" == "" goto gotHome
:: 如果没有的话,那么就设置为当前目录
set "CATALINA_HOME=%CURRENT_DIR%"
:: 如果存在catalina.bat,就跳转okHome标签
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome
set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"
rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec
rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
:: 如果输入参数不为空 那么将参数进行移位操作
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs
:: 调用其他脚本 传递的参数为 version %CMD_LINE_ARGS%
call "%EXECUTABLE%" version %CMD_LINE_ARGS%
:end
支付宝 微信