Stewart Stremler wrote:
begin quoting John H. Robinson, IV as of Mon, Sep 11, 2006 at 11:49:11AM -0700:
[snip]
sh is too easy:
$ for i in `lynx -dump http://www.google.com/supported_domains`; do echo "RewriteCond
%{HTTP_REFERER} ^http://www$i [OR]"; done > exclude_list
Didn't say it was hard.
(And, as carl pointed out, you left out a 'feature'.)
perl is a bit more difficult, as one would likely want to use a perl
module for the http stuff. Bah! Why bother? A shell one-liner is all
that is needed.
There's more than one way to do it. What matters is getting it done
in a timely manner.
You could also use awk or sed for a one-liner approach as well. Any
takers?
Don't need anything as complicated as awk (<heh>), just sed'll do.
get the text, filter on things that start with ^.goog, _and_ which
end with ".??" (which omits header and .com), substitute and print
This is all one line, of course, about 130 chars including a few
unnecessary ones..
GET http://google.com/supported_domains | sed -ne
's/^\.goog.*\...\b/RewriteCond %{HTTP_REFERER} ^http:\/\/www& [OR]/p'
> exclude_list
GET is a handy part of perl-libwww-perl
However, trying for the one-liner may be a false optimization -- I would
say that a "usable" one-liner needs to be < ~80 characters. If it's too
much longer, it's wrapping across multiple lines, and only technically
qualifies as a one-liner -- but not in spirit.
Yeah, but for truly throwaway scripts, I do sometimes go multi-line.
The worst thing about multi-line is fixing typos <sigh>.
I do think your shell-variable abbreviations help readability if you
want a reusable or publishable script.
I'm not motivated to follow through, but it could all be done in shell
(bash2, anyway) without sed. Without any web interface, either, if you
want to throw in an exec 3<> /dev/tcp/64.233.167.99/80 and echo the
proper http request out to &3 and read back in from &3.
Regards,
..jim
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg