如何检测 Linux 机器上是否安装了 Tomcat 和 Ant?

3

我正试图在我的Linux机器上安装Tomcat和Ant,但在安装它们之前,我只需要检查它们是否已经安装。

关于Tomcat:

我进行了大量的谷歌搜索,并在以下目录中搜索了Tomcat:

/usr/local/, /opt/, /usr/share/

但是我在上述任何路径中都没有找到tomcat文件夹,这是否表示tomcat未安装?所以实际上

1. what is the path to `look/find` exactly to know/check whether tomcat is installed or not in 
   all linux machines
2. what will be the path the tomcat will be installed exactly after installation
3. How to find the version of tomcat on any linux machine (if tomcat already installed) 
4. Whether there are any commands to look for both whether `tomcat` installed and `ant` 
   installed

关于Ant:

我通过谷歌搜索得到以下命令,执行后得到以下结果:

sh-4.2$ ant -v

结果

sh-4.2$ ant -v
Apache Ant(TM) version 1.8.2 compiled on November 21 2011
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed

所以实际上
1. Does the above result mean that `Ant` is installed ? or not ?
2. what is the path to `look/find` exactly to know/check whether ant is installed or not in 
   all linux machines
3. what will be the path the `ant` will be installed exactly after installation
4. How to find the version of `Ant` on any linux machine (if Ant already installed) 
2个回答

3

通常,您可以检查它们是否在$PATH上,如果它们不在$PATH上,请安装一个。

对于ant:

ant -v 表示详细信息,ant -version 打印其版本。

   -help, -h
          print help on the command line options

   -projecthelp, -p
          gives information on possible targets for this project

   -version
          prints the version number and then exits ant

   -quiet, -q
          be extra quiet

   -verbose, -v
          be extra verbose

   -debug, -d
          print debugging information

   -emacs, -e
          produce logging information without adornments

   -logfile <file>, -l <file>
          use the given file to output log to

   -logger <classname>
          the class which is to perform logging

   -listener <classname>
          add an instance of the given class as a project listener

   -noinput
          do not allow interactive input

   -buildfile <file>, -file <file>, -f <file>
          use  the  given buildfile instead of the default build.xml file.
          This is the ant equivalent of Makefile

   -D<property>=<value>
          use value for the given property

   -keep-going, -k
          execute all targets that do not depend on failed target(s)

   -propertyfile <file>
          load all properties from file with -D properties  taking  prece-
          dence

   -inputhandler <class>
          the class which will handle input requests

   -find <file>, -s <file>
          (s)earch  for  buildfile  towards the root of the filesystem and
          use it

   -nice number
          A niceness value for the main thread: 1 (lowest)  to  10  (high-
          est); 5 is the default

   -nouserlib
          Run ant without using the jar files from ${user.home}/.ant/lib

   -noclasspath
          Run ant without using CLASSPATH

   -autoproxy
          Java 1.5+ : use the OS proxies

   -main <class>
          override ant's normal entry point

对于Tomcat:

如果Tomcat/bin在$PATH变量中,version.sh会打印出版本号。


对于Ant:找到Ant的版本没问题,但在Linux上Ant将被安装在哪个路径/位置? - Shiva Krishna Bavandla
为什么需要确认这些文件夹,你可以将其安装到任何想要的文件夹中。通常我通过在 /usr/local/tomcat 创建软链接来引用 tomcat,这样就可以通过在另一个文件夹中安装新版本并更改软链接来升级版本。 - StarPinkER
我很高兴能够找到Ant的路径和版本,例如"which ant"和"ant -version",但是对于Tomcat呢?当我执行echo $PATH时,结果是/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin。 - Shiva Krishna Bavandla
实际上我正在用Python编写一个服务器准备脚本,它将检查所有软件的可用性,比如Tomcat、Ant、Apache、Java等。在安装Java之前,我正在尝试动态地检查所有Linux机器上Tomcat和Ant的可用性。 - Shiva Krishna Bavandla
我们能否在这里继续讨论:http://chat.stackoverflow.com/rooms/24874/discussion-between-shiva-krishna-and-jermaine-xu - Shiva Krishna Bavandla
显示剩余7条评论

0

对于Linux Ubuntu 18.04:

Go to terminal and command:$ sudo systemctl status tomcat

这个命令还可以显示Tomcat是否正在运行(如果已经安装)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接