tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Mikusa <dmik...@pivotal.io>
Subject Re: How a script can determine latest version of Tomcat
Date Thu, 04 Sep 2014 18:46:49 GMT
On Thu, Sep 4, 2014 at 1:48 PM, David P. Caldwell <
david@code.davidpcaldwell.com> wrote:

> I have a small program that downloads and installs an arbitrary
> version of Tomcat, using the API provided by Apache to select the
> proper mirror, and so forth.
>
> The script currently takes the Tomcat version as an argument. My
> script provides a default (which in my case is the latest version of
> Tomcat 7), but I have to manually update that default whenever I
> notice a new version has been released.
>
> What would be the best way for the script itself to determine the
> latest available version? Obviously I would give points for "easy" and
> points for "robust," knowing that those two things might be in
> conflict.
>
> I can think of many horrifying ways to do it:
>
> * loop through integers starting with the last known version,
> attempting to download 7.0.x, until getting a 404
> * scraping and parsing the HTML at
> http://archive.apache.org/dist/tomcat/tomcat-7/, which I expect is
> rather stable
>

I did this recently for Tomcat 8.  Here's the command I used, which works
on my Mac.

   LATEST_VERSION=$(curl -s http://tomcat.apache.org/download-80.cgi | grep
"<h3 id=\"8.0." | xpath '/h3/text()' 2>/dev/null)

A slight variation works on Ubuntu if you install xpath.

   LATEST_VERSION=$(curl -s http://tomcat.apache.org/download-80.cgi | grep
"<h3 id=\"8.0." | xpath -e '/h3/text()' 2>/dev/null)

I'm sure there are other ways to do it, this was just the first one I put
together that worked for me.

Dan

So my challenge isn't coming up with *a* way to do it, but coming up
> with the best way.
>
> Suggestions?
>
> -- David P. Caldwell
> http://www.davidpcaldwell.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message