I'm a rabid Linux fan. I write books about it, I have servers running it, and
I even have various flavors of Linux as dual-boot defaults on my PCs. But
keeping up with Linux news can be a bit of effort, particularly if I want to
have that up-to-date news on a Web page, rather than in an RSS Aggregator.
Fortunately, it's a matter of ten minutes of shell script programming to
remedy this. In this article, I'll show you step-by-step exactly how to
create a cron job that'll automatically create an HTML file that contains the
latest headlines from LinuxWorld.com. Just don't tell their Webmaster! :-)
Getting to the Right Page
Like many sites, LinuxWorld.com has "XML" buttons on its various category
pages, so it takes only a few seconds to identify that
http://www.linuxworld.com/topic_content/c_news.rss is the URL of the RSS
feed for LinuxWorld.com's news.
Now, to tap into ... (more)
If the print gods are with us, this time, after seven previous columns, we'll
finally have a shell script that you can type in and experiment with.
Imagine!
The last column addressed the challenges of generating a reasonably random
number to enable us to write a rudimentary hi-low guessing game. After
experimentation, we settled on using the date command with some fancy
footwork to generate a number between 1..x as shown here:
toguess="$(expr `date +%S` % 20 + 1)"
In this case, the result is a quasi-random number between 1 and 20. Good
enough for our game, which involves the com... (more)
What happens when you turn a perfectly good Apple PowerBook into a tri-boot
system with Mac OS X, Yellow Dog Linux, and Ubuntu Linux? Read on to find
out.
Mac OS X is built of two components: Darwin, the BSD-based Unix
underpinnings, and Aqua, the beautiful graphical user interface we Mac heads
have all grown to love. However, there are other operating systems and other
work environments that can be installed on an Apple system, based on popular
open source Linux applications.
If you're looking for Intel-based versions of Linux, there are dozens and
dozens, but the PowerPC chip... (more)
Last month I talked about the file-related options to the test command and
how that helps you create smart and sophisticated shell scripts. This time I
want to look at the additional conditions available for looping and flow
control. String TestsOne common test in shell scripts is to ascertain whether
something the user has typed in or something pulled out of a data stream or
file matches a specific pattern or string. The first of these tests is -z
$string, which returns true if the string is zero length, false otherwise.
Consider this snippet:
empty="" if [ -z $empty ] ; then e... (more)
By this point in our discussion you should be comfortable with the idea of
the three file descriptors associated with the Linux command line: stdin,
stdout, and stderr (pronounced "standard in," "standard out," and "standard
error"). If you're using a descendant of the Bourne Shell (such as Bash), you
also learned last month how to use the x>&y notation to redirect the
different descriptors from the command line, and therefore from within a
script too. This time I'll turn my attention to the C shell with its
different command-line syntax.
My focus here is ultimately on shell scr... (more)