[colug-432] Command-line Snow Emergency Level
Mike Plemmons
mikeplemmons at gmail.com
Thu Feb 19 19:44:04 EST 2015
This is a cool little script but for anyone running Debian 8.0 there is a
change to the xpath command. The '-q' argument fails to work. I have to
use this argument structure.
xpath "$tmpfile" "//div[@class='main']/div//text()"
Usage:
/home/mike/perl5/bin/xpath [filename] query
On Wed, Feb 18, 2015 at 10:32 AM, Rob Funk <rfunk at funknet.net> wrote:
> In case you need a command to quickly get the current Franklin County
> snow emergency level:
>
>
> #!/bin/sh
> # Franklin County Snow Emergency Level
> #
> # Required commands:
> # curl
> # xpath (from libxml-xpath-perl package)
> # html2, 2xml (both from xml2 package)
>
> tmpfile="/tmp/snow-$$.xhtml"
> url=https://sheriff.franklincountyohio.gov/info/snow-emergency-levels.cfm
>
> xhtml_cleanup() {
> html2 | 2xml
> }
>
> ##
>
> curl -s "$url" | xhtml_cleanup > "$tmpfile"
> status=$?
> if [ $status -gt 0 ]; then
> rm -f "$tmpfile"
> exit $status
> fi
>
> xpath -q -e "//div[@class='main']/div//text()" "$tmpfile"
>
> rm "$tmpfile"
>
> #################################################################
>
> Those two package names are on Ubuntu. YMMV.
>
> Sending you a message when this changes, or handling other counties,
> are left as an exercise for the reader.
>
>
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20150219/93484cd5/attachment.html
More information about the colug-432
mailing list