Channels ▼
RSS

JVM Languages

Automating Release Notifications

Source Code Accompanies This Article. Download It Now.


Command-Line Example

I initially began the automation process at the command line. A variety of tools can be used to retrieve web pages from the command line, including:

Once you retrieve a page, you can parse its content using the ever-useful combination of sed/awk/grep and regular expressions.

So suppose you want to be notified when a new version of Microsoft's Process Explorer is released. Figure 1 is the web page for Process Explorer showing the version information you wish to monitor (v11.04) (www.microsoft.com/technet/sysinternals/utilities/processexplorer.mspx). The following one-line script determines the current version of Microsoft's Process Explorer. I ran this from a cygwin (www.cygwin.com) bash session:


wget -qO- http://www.microsoft.com/technet/
sysinternals/utilities/processexplorer.mspx | sed
's/<[^>]*>//g' - | grep -o -m1 -P "v[\d\.]{4,}"

[Click image to view at full size]

Figure 1: Web page for Process Explorer.

The output (at this writing) is as expected: v11.04. Note that:

  • The wget -qO- option causes the retrieved page to be sent to stdout instead of a file.
  • The sed 's/<[^>]*>//g' command deletes HTML tags (any text beginning with "<" and ending with ">"). Because you're after the page content, you dutifully ignore HTML tags.
  • The grep -o -m1 -P "v[\d\.]{4,}" command outputs the first match of the given Perl regular expression. You look for the "v" character followed by four or more digits or "." characters.

The script relies on a common editorial pattern: The most current information should appear first, hence the ability to simply use the first match. If the page listed multiple releases in chronologically ascending order, then additional processing would be required to grab the last match instead of the first match.

The command-line approach works well and can be readily incorporated into other scripts to provide additional functionality (automatic downloading, sending e-mail notifications, and so on). However, there are inherent limitations to this command-line approach:

  • Checking and processing multiple websites must be done sequentially.
  • A nonresponsive website can slow down the entire process if you check multiple websites sequentially.
  • Reviewing, sorting, and filtering results requires additional work.
  • Skipping a specific website from a set of websites to monitor is problematic.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video