| |||||||||||
This backlog unfortunately does effect this newsletter. Rather than abandoning you folks to the high seas, I'm going to restructure how this newsletter is put together. That should help me get it out on time a lot easier - and at a good quality - without completely driving me mad as I try to keep up with everything I'm supposed to be doing! So, the new plan is this. The EGGS, CHICKS, and PENGUINS sections will rotate, with only one of these available in each issue. The VOICE, CLICK, and MAN entries will stay in every issue. This should work a lot better than me having to cut all three down into tiny chunks (another restructuring option). Who wants to get just one paragraph per week on each topic?? Digitally Yours,
This week we have a guest EGG column. This article starts a
short EGG series on shell scripting, so enjoy!
SHELL SCRIPTS 101
If you're following the travails of the Penguin by reading this
newsletter, you're doubtless already exploring the nooks and
crannies of Linux. If you haven't yet, you'll definitely want to
pop open a Terminal window and explore the command line, because
it's really only on the command line that you can see the
remarkable power and capabilities of Linux.
For this tutorial, I'm going to step you through a simple,
elegant, and darn useful shell script that'll save you from
saying, "What CD was that file on?" It's a CD-ROM catalog utility.
Let's jump in!
WORKING WITH CDROMS
Red Hat Linux, which is what I'm focusing on, offers the
delightful capability of automounting CD-ROMs as they're inserted
into your Linux system. They're actually mounted as /dev/cdrom on
/mnt/cdrom, which means that you can use
Taking that as a jumping-off point, it shouldn't be too hard to
write a script that uses find to list all the files and
directories on a disk and save it to a central database file. To
find a file, then, just use
The essential line of code is:
But, there are lots of nuances... first off, we need to have the
script both index CD-ROMs and search for files in the CD-ROM list.
That can be done by having searches require a pattern, but the
script invoked without a pattern be a request to index a CD-ROM...
IF it's mounted! How do you test for that? Using
So we can grep for '/dev/cdrom' in the script:
There's a little bit of shell script magic going on here that's
worth explaining, at least briefly. First off, we're doing the
SMART AND LOGICAL TESTS
As with most decent shell scripts, it seems like cdcatalog
actually has more tests than anything else. For example, what if
the user invokes the script with more than one argument? Output
an error:
What if the database isn't readable? Another error condition:
So let's look at the first chunk of the script in its entirety:
If a pattern is specified, ("$1" isn't a null string) and the
database is readable (! -r $db means it's not readable), then grep
for $1 in the database, ignoring case issues (the -i flag) and
pipe the output through more in case there's a lot of it.
Assuming there's a database file built and updated, we're rockin:
... next time we'll look at the second block of code, the second
that actually builds the database. Stay tuned! Submit a Resource | Discuss | Recommend It!
I thought I'd throw in two interesting e-mails this week:
Sam writes:
"'If you get really stuck, start up X-Chat and log into
irc.debian.org or irc.openprojects.net and join channel #debian.
That is one busy chat room, with Debian Linux experts present
24/7, willing to help.'
"openprojects has long since been transformed into
irc.freenode.net. If interested, and for more information on the
change, you might drop by http://freenode.org/."
Jose writes:
"The whole changelong for version 3.3 can be found at http://www.knoppix.net/forum/viewtopic.php?t=5017." Submit a Resource | Discuss | Recommend It!
Stefan writes:
"Requirements (according to the website):
Submit a Resource | Discuss | Recommend It!
"Love your page as it is very informative; just wondering if you could touch on a subject that is driving me a little batty at the moment.Dee-Ann responds:
Ah, clustering. That's what I was teaching in California! To start
with, type
ARP (Address Resolution Protocol) maps IP addresses to MAC addresses. A MAC address is a unique series of hexadecimal numbers that specifically identifies only one Ethernet card on the planet. This helps to make sure that the Internet doesn't descend into new levels of chaos where packets are bouncing around every which way trying to find where they belong. Now, your problem is with RARP. That's just the reverse, where MACs are mapped to IPs. Most cluster installers at some point either need to be able to automatically learn what the MAC address is for each node using a network boot (something that isn't supported still in many modern BIOS's), or need you to tell them what MACs it's trying to talk to so it can use DHCP to then assign IP addresses to each node's Ethernet card. You can find out if your nodes support network booting by rebooting them and seeing if you're offered more than one pre-BIOS option. For example, you might be told to press Del to enter Setup, or F12 to network boot. When a machine is network booted, it broadcasts its MAC among other things out onto the network. If your BIOS doesn't support network booting, then the most painful way to set up for netbooting is to place the netboot code onto a computer chip and then solder that chip onto your Ethernet cards. Frankly, that sounds like something to avoid when all possible.
Some cluster installers offer an option for creating a netboot
floppy disk instead. However, these require you to first learn the
MACs for each of your Ethernet cards and, typically, enter those
into a file that you can then have the cluster installation
routine load. You can use a lot of different techniques to, one by
one, learn those MACs. A simple one is to use either a bootable
Linux distribution such as Knoppix, or a rescue disk from a full
Linux distribution such as Red Hat, in order to boot and access a
shell where you can type Hope this helps! |
Cool Tools: GnomeDomains GnomePortable Gnomies.com GnomeSavings GnomePersonals GnomeJobs
Reading Materials: Windows Daily Digital Media Tech Specialist Penguin Shell Apple Core Web Weekly Technology News File Of The Day RSS Resource
Our Community:
Contact Us:
Question: which group is 250,000+ strong and always looking for stuff to make their personal and professional lives run smoother?
©1996-2003, Lockergnome LLC. ISSN: 1095-3965. All Rights Reserved. Please read our Terms of Service. Web site hosted by Webair. Domain registered at DNS Central. Powered by Lyris ListManager. Chris Pirillo fueled by Peet's Coffee. Headers provided by Habeas. Statistics provided by Urchin. | ||||||||||