如何使用shell获取下载tomcat服务器的最新链接

编程入门 行业动态 更新时间:2024-10-26 20:33:28
本文介绍了如何使用shell获取下载tomcat服务器的最新链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我编写了一个shell脚本来下载和安装tomcat服务器v (8.5.31).wget http://www.us.apache/dist/tomcat/tomcat-8/v8.5.31/bin/apache-tomcat-8.5.31.tar.gz 工作正常,但是一旦版本更改为 9.0.10,它就开始出现 404 not found 错误.那么我应该怎么做才能始终获得最新版本.

I have written a shell script to download and install the tomcat server v (8.5.31). wget http://www.us.apache/dist/tomcat/tomcat-8/v8.5.31/bin/apache-tomcat-8.5.31.tar.gz It was working fine, but as soon the version got changed to 9.0.10, it started giving error as 404 not found. So what should I do to get the latest version always.

推荐答案

TL;DR

TOMCAT_VER=`curl --silent http://mirror.vorboss/apache/tomcat/tomcat-8/ | grep v8 | awk '{split($5,c,">v") ; split(c[2],d,"/") ; print d[1]}'`
wget -N http://mirror.vorboss/apache/tomcat/tomcat-8/v${TOMCAT_VER}/bin/apache-tomcat-${TOMCAT_VER}.tar.gz

我遇到了同样的挑战.但是,对于我的解决方案,我需要不断变化的最新 8.5.x Tomcat 版本.

I encountered the same challenge. However for my solution I require the latest 8.5.x Tomcat version which keeps changing.

由于下载Tomcat的URL保持不变,只是版本发生了变化,我发现以下解决方案适合我:

Since the URL to download Tomcat remains the same, with only the version changing, I found the following solution works for me:

TOMCAT_VER=`curl --silent http://mirror.vorboss/apache/tomcat/tomcat-8/ | grep v8 | awk '{split($5,c,">v") ; split(c[2],d,"/") ; print d[1]}'`
echo Tomcat version: $TOMCAT_VER
Tomcat version: 8.5.40

grep v8 - 返回具有所需版本的行:

grep v8 - returns the line with the desired version:

<img src="/icons/folder.gif" alt="[DIR]"> <a href="v8.5.40/">v8.5.40/</a>                2019-04-12 13:16    - 

awk '{split($5,c,">v") ;split(c[2],d,"/");print d[1]}' - 提取我们想要的版本:

awk '{split($5,c,">v") ; split(c[2],d,"/") ; print d[1]}' - Extracts the version we want:

8.5.40

然后我继续使用提取的版本下载 Tomcat:

I then proceed to download Tomcat using the extracted version:

wget -N http://mirror.vorboss/apache/tomcat/tomcat-8/v${TOMCAT_VER}/bin/apache-tomcat-${TOMCAT_VER}.tar.gz

这是使用 curl、grep 和 awk 从中提取版本的完整 curl 响应:

This is the complete curl response from which the version is extracted using curl, grep and awk:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
 <head>
  <title>Index of /apache/tomcat/tomcat-8</title>
 </head>
 <body>
<h1>Index of /apache/tomcat/tomcat-8</h1>
<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a>                    <a href="?C=M;O=A">Last modified</a>      <a href="?C=S;O=A">Size</a>  <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[PARENTDIR]"> <a href="/apache/tomcat/">Parent Directory</a>                             -   
<img src="/icons/folder.gif" alt="[DIR]"> <a href="v8.5.40/">v8.5.40/</a>                2019-04-12 13:16    -   
<hr></pre>
<address>Apache/2.4.25 (Debian) Server at mirror.vorboss Port 80</address>
</body></html>

这篇关于如何使用shell获取下载tomcat服务器的最新链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 03:52:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1389379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   链接   服务器   最新   tomcat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!