2001 10 04


                    LINUX NEWS
        RESOURCES & LINKS FROM BRAINBUZZ.COM
              Thursday, October 4, 2001
    Read By Over 7,000 Linux Enthusiasts Weekly!


TABLE OF CONTENTS

1) Sean’s Notes

2) Linux News

World's Greatest Editor
Time to stand up to Microsoft
Star Office 6.0 beta Released
The Freedom to use Codes

3) Linux Resources

Programming Linux Games
SQL Databases for Linux
Information Warfare: How to Survive Cyber Attacks
Say Hello to PAM
Three Minutes With Security Expert Bruce Schneier

4) App o’ the week

~~~~~~~~~~~~~~~~~~~~~~ ADVERTISEMENT ~~~~~~~~~~~~~~~~~~~~~~~

We GUARANTEE you will pass your exam or you get your money back!

Win2K Titles Only $99.95 each (normally $149.95) A+ Core & Elective Only $99.95 (normally $249.95) INET+ or Network+ Only $79.95 each (normally $149.95) Cisco 2.0 titles Only $149.95 each (normally $249.95)

Add our Audio Quizzer for only $19.95 for each cassette or CD. CALL (800) 845-8569 FOR MORE INFORMATION OR VISIT US AT http://ad.brainbuzz.com/?RC06&AI70







For information on how to advertise in this newsletter
please contact mailto:adsales@BrainBuzz.com or visit
http://cramsession.brainbuzz.com/marketing/default.asp

-------------------------
1) Sean's Notes
-------------------------

If there is something you find yourself doing often, it's
probably worth scripting.  Even if it's a matter of running
a couple of other scripts, the goal is to save some time.
It may seem like a waste of time at first, but add up all the
time you spend doing the task, and think of what else you
could be doing in that time.  If it's work-related, then
wrapping it up in a script (well commented, of course), lets
you get away with not having to explain it to everyone who
does the task themselves, or has to fill in for you on
vacation.  It's all part of our nature as Unix jocks to be
lazy.  Not "slacker lazy", but "work smarter, not harder
lazy".

The more you learn about scripting, the more places you'll
find it to be handy.  An example will help here.

Every week when I write this newsletter, I start off with a
file called template.txt, which has placeholders for every
news and resource item, plus the headers and footers.  I
copy it into a file called YYYYMMDD.txt, and begin my work
on it.  Once I've written the article and added the links
in, two things remain before I submit it, namely spell
checking, and filling in the "Table of Contents" section.

The latter is a real pain, and is the first thing that has
to be fixed.  After the first two weeks of cutting and
pasting, I knew it had to be scripted.  I came up with a
simple solution -- a Perl filter that extracts the headlines
from the .txt file, leaving me with only two cut and pastes
to do (versus nine plus a lot of scrolling).  It's actually
a pretty simple script:

#!/usr/bin/perl
while(<STDIN>) {
  if (/^-+$/){
    $a=<STDIN>;
    print "\t$a";
    $a=<STDIN>;
  }
}

The outer loop reads in input from the standard input.
Perl is a pretty relaxed language, so when I get the current
line from the <STDIN> statement, it stores it in a special
variable called $_  (that's a dollar sign, followed by an
underscore).

Next, I want to perform a regular expression search on the
current line, to see if it is beginning the title of one of
my links.  Everything between the /'s is called the pattern,
or a regular expression.  In this case, the pattern begins
with a carat, meaning "beginning of line".  Next is a dash
followed by a plus sign.  The plus sign means "match one or
more of the preceding".  The final dollar sign means end of
line.  So, my regexp will only match a line that starts with
a dash, ends with a dash, and has nothing but dashes in
between.  Since I already have the current line in $_, I
don't have to explicitly tell Perl where to look because
it's the default.  Otherwise, I'd have to tell it to do a
regular expression search with the =~ operator:

if ($_ =~ /^-+$/) {

Once I've found the line in question, I read the next line
with my title, and print it (with a tab in front for easier
pasting):

$a = <STDIN>;
print "\t$a";

And then, because the next line is also full of dashes, I
do a fake read to advance the file to the next line.

This week, it looks like this:

$ cat 20011004.txt | ./makecontents.pl
	TABLE OF CONTENTS
	World's Greatest Editor
	Time to stand up to Microsoft
	Star Office 6.0 beta Released
	The Freedom to use Codes
	Programming Linux Games
	SQL Databases for Linux
	Information Warfare: How to Survive Cyber Attacks
	Say Hello to PAM
	Three Minutes With Security Expert Bruce Schneier

A few clicks, and I'm done.  Is that lazy enough for me?
Not anymore.  It's been almost a year of cutting and
pasting; it's about time I had the script make the changes
directly.

The template I start off with has the phrase "Headline"
where I'm supposed to put the headline (shows how smart
my editor thinks I am).  I'm going to use that to my
advantage now.

What I came up with (after several tries) is:


<div class="highlight"><pre><code class="perl"><span class="c1">#!/usr/bin/perl -w</span>
<span class="k">use</span> <span class="n">strict</span><span class="p">;</span>

<span class="c1"># Need a filename to function</span>
<span class="nv">$ARGV</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">||</span> <span class="nb">die</span> <span class="s">&quot;Gimme a filename\n&quot;</span><span class="p">;</span>

<span class="c1"># Open one for reading, and a backup stream for writing</span>
<span class="nb">open</span> <span class="n">FILE</span><span class="p">,</span> <span class="s">&quot;&amp;lt;$ARGV[0]&quot;</span> <span class="ow">or</span> <span class="nb">die</span> <span class="s">&quot;Error opening $ARGV[0]\n&quot;</span><span class="p">;</span>
<span class="nb">open</span> <span class="n">BACKUP</span><span class="p">,</span> <span class="s">&quot;&gt;$ARGV[0].bak&quot;</span> <span class="ow">or</span> <span class="nb">die</span> <span class="s">&quot;Error opening backup\n&quot;</span><span class="p">;</span>

<span class="k">my</span> <span class="nv">$newsletter</span><span class="p">;</span>

<span class="k">while</span><span class="p">(</span><span class="o">&amp;</span><span class="ow">lt</span><span class="p">;</span><span class="n">FILE</span><span class="o">&gt;</span><span class="p">)</span> <span class="p">{</span> <span class="c1"># Run through the file</span>
   <span class="k">print</span> <span class="n">BACKUP</span><span class="p">;</span>  <span class="c1"># Write to the backup file</span>
   <span class="nv">$newsletter</span> <span class="o">.=</span> <span class="nv">$_</span><span class="p">;</span>  <span class="c1"># All that we&#39;ve read so far goes here</span>
   <span class="k">if</span> <span class="p">(</span><span class="sr">/^-+$/</span><span class="p">){</span>    <span class="c1"># We found the beginning of a header</span>
   <span class="k">my</span> <span class="nv">$a</span><span class="o">=&amp;</span><span class="ow">lt</span><span class="p">;</span><span class="n">FILE</span><span class="o">&gt;</span><span class="p">;</span>  <span class="c1"># read it in</span>
   <span class="k">print</span> <span class="n">BACKUP</span> <span class="nv">$a</span><span class="p">;</span>  <span class="c1"># Write to the backup file</span>
   <span class="nv">$newsletter</span> <span class="o">.=</span> <span class="nv">$a</span><span class="p">;</span>
   <span class="k">unless</span> <span class="p">(</span><span class="nv">$a</span> <span class="o">=~</span><span class="sr"> /TABLE OF CONTENTS/</span><span class="p">)</span> <span class="p">{</span>
	<span class="c1"># Substitute the first &quot;Headline&quot; for the real one</span>
	<span class="nv">$newsletter</span> <span class="o">=~</span> <span class="sr">s/[ \t]+Headline\n/\t$a/</span><span class="p">;</span>
   <span class="p">}</span>
   <span class="nv">$a</span><span class="o">=&amp;</span><span class="ow">lt</span><span class="p">;</span><span class="n">FILE</span><span class="o">&gt;</span><span class="p">;</span>  <span class="c1"># Read next line</span>
   <span class="k">print</span> <span class="n">BACKUP</span> <span class="nv">$a</span><span class="p">;</span>  <span class="c1"># Write to the backup file</span>
   <span class="nv">$newsletter</span> <span class="o">.=</span> <span class="nv">$a</span><span class="p">;</span>
	<span class="p">}</span>
<span class="p">}</span>
<span class="nb">close</span> <span class="n">BACKUP</span><span class="p">;</span>
<span class="nb">close</span> <span class="n">FILE</span><span class="p">;</span>

<span class="c1"># Good work... update the original file</span>
<span class="nb">open</span> <span class="n">FILE</span><span class="p">,</span> <span class="s">&quot;&gt;$ARGV[0]&quot;</span> <span class="ow">or</span> <span class="nb">die</span> <span class="s">&quot;Error opening $ARGV[0] for writing\n&quot;</span><span class="p">;</span>
<span class="k">print</span> <span class="n">FILE</span> <span class="nv">$newsletter</span><span class="p">;</span>
<span class="nb">close</span> <span class="n">FILE</span><span class="p">;</span>
</code></pre></div>


I've added a lot of comments, but it's basically the same
thing as before, just not written as a filter (ie it reads
and writes the files by itself).  You'll notice I write a
backup copy as I go along, it's just good practice!  I'm not
perfect, so I don't expect my scripts to be.  Everything is
pretty basic, except the real smarts of the script:

unless ($a =~ /TABLE OF CONTENTS/) {
	# Substitute the first "Headline" for the real one
	$newsletter =~ s/\[ \t]+Headline\n/\t$a/;
}

Here, I'm skipping over the header for table of contents.
Since I have the entire document up until the current line
in memory, I can perform a substitution on it, replacing
the placeholder headline, with what I actually read in.
This is a handy thing in Perl:

$variable =~ s/old/new/;

substitutes "old" for "new" in $variable.

So, in my quest for eternal laziness, I spent a bit more time
than usual on this article, but ended up with a script that
saves me some repetitive work that I dislike.  A few more
lines, and it could fill in the date at the top, and maybe
even run a spell check at the end.  If only the status
reports I have to write for my boss were as easy...Wait...
This article gives me an idea!

Long live the \[lazy] Penguin,

Sean
mailto:swalberg@brainbuzz.com

Visit the Linux News Board at
http://boards.brainbuzz.com/boards/vbt.asp?b2

-------------------------
2) Linux News
-------------------------

-----------------------
World's Greatest Editor
-----------------------
VIM, the King of all editors (or at least a clone thereof),
announces the release of 6.0. There's a whole whack of new
features added to make a great editor even greater.

http://www.vim.org/announce/vim-6.0

-----------------------------
Time to stand up to Microsoft
-----------------------------
This scathing attack on Microsoft's desktop operating systems
is too good not to pass along. The author calls on people to
jump on the Linux bandwagon, citing that Microsoft's new
policies are making it even more cost-effective.

http://www.zdnet.com/zdnn/stories/news/0,4586,2815189,00.html

-----------------------------
Star Office 6.0 beta Released
-----------------------------
This version of StarOffice purports to be easier on memory,
and doesn't take over your entire desktop. Two things I
immediately noticed were that setting up PDF output is very
easy, and that TrueType fonts can be used (an extra step, but
it is well documented). A vast improvement over 5.2...I'll
just hope it's as stable.

http://www.sun.com/staroffice/6.0beta/

------------------------
The Freedom to use Codes
------------------------
Linux is all about freedom, which is why many Linux enthusiasts
are also Cryptography buffs. In the wake of the US tragedy,
there are now calls for increased restrictions on Crypto.
A reporter reflects on the folly of such a plan.

http://news.cnet.com/news/0-1272-210-7320099-1.html

-------------------------
3) Linux Resources
-------------------------

-----------------------
Programming Linux Games
-----------------------
If you've got a bit of programming knowledge under your
belt, and wanted to try your hand at writing games for
Linux, this is the book for you. It covers the basics of
the SDL API, along with some other game writing APIs, and
develops a complete working game. Well written, and full
of useful information.

http://itresources.brainbuzz.com/tutorials/tutorial.asp?t=S1TU1475

-----------------------
SQL Databases for Linux
-----------------------
"So you find you need to store some data on your Linux
system, and are wondering what program to use... There are
a vast array of database systems available for use on Linux.
Some are simple, some sophisticated, some cheap, some
expensive. One of the first things you ought to do is ask
yourself what you need to do with the database, as that is
critical to bringing the number of choices down from
'stupendously bewildering' to merely 'astoundingly many'."

http://freshmeat.net/articles/view/305/

-------------------------------------------------
Information Warfare: How to Survive Cyber Attacks
-------------------------------------------------
With all the news about terrorism and viruses lately, this
book couldn't have come at a better time. A very interesting
read, "Information Warfare" covers the non-technical aspects
of Cyber Terrorism and other attacks.

http://itresources.brainbuzz.com/tutorials/tutorial.asp?t=S1TU1467

----------------
Say Hello to PAM
----------------
PAM, the Pluggable Authentication Modules, can be a great
thing if you know how to use them. This article from
O'Reilly Net has some great instructions on the format of
the configuration files, and the various modules available.

http://linux.oreillynet.com/pub/a/linux/2001/09/27/pamintro.html

-------------------------------------------------
Three Minutes With Security Expert Bruce Schneier
-------------------------------------------------
Any time Bruce talks, I'll listen. This time it's on
security (or lack thereof) in Microsoft products, and the
merits of full disclosure. He regularly speaks out on topics
close to the UNIX world, such as freedom and Open Source.

http://www.pcworld.com/news/article/0,aid,63806,00.asp

-------------------------
4) App o' the week
-------------------------
"2diskXwin" is a distribution of Linux that...guess what...
fits on two disks. It features a web browser and Internet
capabilities, so this could work as a very easy remote X
desktop device.

http://www.mungkie.btinternet.co.uk/projects/2diskXwin.htm

-------------------------
(C) 2001 BrainBuzz.com. All Rights Reserved.
-------------------------
-------------------------

         This message is from BrainBuzz.com.

You are currently subscribed to the
   Hottest Linux News and Resources
   as: sean@ertw.com

To un-subscribe from this newsletter by e-mail:
   send a blank email message to:
   mailto:leave-linuxnews-3825955Y@list.cramsession.com

-------------------------------------------------------

To Subscribe to this newsletter by e-mail:
   send a blank email message to:
   mailto:join-linuxnews@list.brainbuzz.com
-------------------------