LINUX GAZETTE

October 2001, Issue 71       Published by Linux Journal

Front Page  |  Back Issues  |  FAQ  |  Mirrors  |  Search (www.linuxgazette.com)

Visit Our Sponsors:

Penguin Computing
Linux NetworX

Table of Contents:

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

Linux Gazette Staff and The Answer Gang

Editor: Michael Orr
Technical Editor: Heather Stern
Senior Contributing Editor: Jim Dennis
Contributing Editors: Ben Okopnik, Dan Wilder, Don Marti

TWDT 1 (gzipped text file)
TWDT 2 (HTML file)
are files containing the entire issue: one in text format, one in HTML. They are provided strictly as a way to save the contents as one file for later printing in the format of your choice; there is no guarantee of working links in the HTML version.
Linux Gazette[tm], http://www.linuxgazette.com/
This page maintained by the Editor of Linux Gazette,

Copyright © 1996-2001 Specialized Systems Consultants, Inc.

The Mailbag



HELP WANTED : Article Ideas

Send tech-support questions, Tips, answers and article ideas to The Answer Gang <>. Other mail (including questions or comments about the Gazette itself) should go to <>. All material sent to either of these addresses will be considered for publication in the next issue. Please send answers to the original querent too, so that s/he can get the answer without waiting for the next issue.

Unanswered questions might appear here. Questions with answers--or answers only--appear in The Answer Gang, 2-Cent Tips, or here, depending on their content. There is no guarantee that questions will ever be answered, especially if not related to Linux.

Before asking a question, please check the Linux Gazette FAQ to see if it has been answered there.



Suggestion on Gazette contents.

Thu, 6 Sep 2001 11:04:37 +0530 (IST)
Atul Sowani ()

I've been TLG reader since long time (almost from the first issue). Some time back, there used to be a column "Graphics Musings" (I hope I've got the name correctly), which used to have information about various graphics packages and utilities. Could you revive that column or a new one on similar lines? i.e., not essentially on graphics utilities alone, but also including other noteworthy utilities too?

Atul, the column was The Graphics Muse by Michael Hammel (, whom I'm cc'ing). His farewell article was http://www.linuxgazette.com/issue46/gm.html Michael stopped writing his Linux Gazette column because (1) he wanted to consolidate his free graphics-related work on one web site (http://www.graphics-muse.org), and (2) he needed to spend more time on paid employment. Nevertheless, Michael remains a friend of Linux Gazette (part of the Clueful Horde) and occasionally answers questions from the Mailbag or helps the Gazette with graphics issues. He is also active in a Colorado Linux users group, if I remember correctly.

If somebody would like to start a new graphics-related series for LG, we'd be glad to publish it. But it can't be called The Graphics Muse since Michael is still using that title.

Since Linux Gazette's articles come from our readers, "we" cannot revive the column, but "you" as a reader can. Even if you're not a graphics expert, if you use Linux graphics programs regularly, you can write about your experiences (and frustrations) with them. It just has to be "new information": stuff that hasn't been published in LG before (or is so old it needs an update), and hasn't been overreported elsewhere.

As for other utilities, those are some of the things Thomas Adam writes about in his series The Weekend Mechanic. If you have any suggestions for topics you'd like to see him cover, e-mail him at . Or send article requests to The Answer Gang () and we'll put them in the Mailbag.

... and having been copied on this, Michael Hammel chimed in ...

Someone actually remembers that column? :-)

Actually, the ".org" address is for my personal stuff. The ".com" address holds the Graphics Muse content. Of course, last year I started dating my high school sweetheart, and now we're married. So I haven't actually had time to update that site in over a year. I hope to get back to it eventually, but its not on the near term schedule.

paid employment. Nevertheless, Michael remains a friend of Linux Gazette

Paid employment is taking precedence these days. Articles on graphics for Linux Journal and Linux Magazine are usually as close as I come to doing 'Muse style writings these days.

(part of the Clueful Horde) and occasionally answers questions from the Mailbag or helps the Gazette with graphics issues. He is also active in a Colorado Linux users group, if I remember correctly.

Sort of. I moved to Houston to be with my (now) wife and her daughter, though I still participate on the Colorado LUGs mailing list (BLUG and CLUE, specifically). I also am Senior Editor for LWN.net and write the On The Desktop page.

If somebody would like to start a new graphics-related series for LG, we'd be glad to publish it. But it can't be called The Graphics Muse since Michael is still using that title.

That's correct. It's still copyrighted by me. I'd hoped to do a series of books under the umbrella "Graphics Muse", but that hasn't happened.

Interesting that someone would remember that column from so long ago. Especially now that graphics on Linux has become big business.

Later.
--
Michael J. Hammel
The Graphics Muse


Asound Ethernet card

Thu, 20 Sep 2001 20:31:24 -0700
Mike Orr ()

Has anybody had any luck with the Asound ALM2 Ethernet card? I usually stick with 3com, epro or ne2000 cards to avoid driver problems, but this one said Linux driver on the box and it was $10, so I thought it was an ne2000 compatible. Turns out it has a RealTek 8139 chip, which corresponds to the experimental 8139too module (Linux 2.4.3). But the driver doesn't recognize the card. "init_module: no such device. Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters."

Thinking it was futile, I looked up the I/O address of the card in /proc/pci and tried "modprobe 8139too io=0xa000". This resulted in, "invalid parameter parm_io".


Linux in other languages

Mon, 3 Sep 2001 15:34:19 +0100
Ravishankar Rajendran ()

I am interested in developing a linux version in Tamil( an Indian language). It would be very helpful, if you can provide an article providing an outline of the process of going about it.

... Mike likes the idea ...

This would make an excellent article, if there's anybody with experience to be able to write it. Even an article on how the Spanish or Chinese versions of Linux were built would be worthwhile.

... Mike also encouraged him to contact those most likely to have experience with language ports ...

Ravishanker, talk with the distributions that already offer multilingual versions of Linux. Linux--and the Unix programs and tools it is bundled with--were originally written in English, but several distributions have appeared in non-English-speaking countries with Linux speaking their language. TurboLinux 6.5 for the iSeries (http://www.turbolinux.com/products/index.html) supports "English, Japanese, Korean, and Simplified and Traditional Chinese with the unified code base", and claims to have the leading support for wide character sets. Conectiva Linux (http://www.conectiva.com) is based in Brazil and offers Portuguese, Spanish and English versions. SuSE (http://www.suse.de) is based in Germany and offers versions in seven Western European languages and Czech. Mandrake, Red Hat and others also offer various levels of multilingual support.

Some of the issues you will face include:

Look through the HOWTOs at http://www.linuxdoc.org. Look at the other-language HOWTOs like the Thai HOWTO, Chinese HOWTO, Danish HOWTO, Esperanto HOWTO, etc. The Font HOWTO may help with font issues. The Keyboard-and-Console HOWTO explains how to set up the text console for different languages. The Unicode HOWTO explains some other aspects of Unicode.

Contact Linux Focus (http://www.linuxfocus.com) and see if they have any advice. Linux Focus is a zine with a lot more non-English-speaking staff than LG.

... and Ravishankar replies ...

Thanks a lot for the help. I will keep you posted on the progress.


Content Suggestion

Fri, 28 Sep 2001 08:34:14 -0700
Boning, Mike ()

After the recent suggestion from the Gartner Group to abandon Microsoft IIS, many companies are going to be looking at moving to Linux/Apache. It would be wise to publish good information regarding comparisons, compatibilities, and particularly migration paths.


GENERAL MAIL



Thinking of and Praying for you

Wed, 12 Sep 2001 22:54:08 +0200
Wiri ()

Hello Linuxg@zette,

Please accept our expression of condolence for the terror that has struck your country. God bless you and America !

Wilf and friends.

Thank you very much, Wilf; I realize this isn't a Linux topic, but I didn't want your message of support to just stand unanswered. Just a bit of military historical perspective: at one point, Rome lost three legions and one of their governors in a single ambush in the Teutoburger Forest. Never before had they suffered a disaster of those proportions; nothing even close. The result? Roman armies marched; and afterwards, there was not enough left of the tribes that had attacked them to even bother Rome for *five centuries.*

"We have awakened a sleeping giant and filled him with a terrible resolve." -- Admiral Yamamoto, after Pearl Harbor

Thank you again. And thank you to all of our friends who are with us in compassion, caring, and spirit.

Ben Okopnik
US Army veteran

See also the News Bytes and TAG columns for some more words from the Linux Gazette staff on this topic. -- Heather


Ben's fame to claim???

Wed, 5 Sep 2001 22:31:20 +0100 (BST)
Thomas Adam ()

Dear Ben (and others),

I just thought that you and the rest of the team at the LG, would like to know that I was flicking through a friends copy of a British magazine called PCPlus. Although this is mostly orientated towards Windoze users, they do have a Linux section.

In this section the subject of shell scripting was being taught. I was not impressed with their content. The author of the article referred to shell scripting as a "dos batch file" equivalent, but gave no mention that BASH in fact has many boolean logic control-structures. But that is by-the-by.

The real reason why this e-mail is being sent to you, is that in one of the references, they pointed it to Ben Okopnik's article on The basics of shell languages (in issue 52). It is nice to know that the LG is used in such a context.

Keep up the good work guys,
Regards,
Thomas Adam -- The Linux Weekend Mechanic

<smile> Always good to hear that somebody is getting good use out of this stuff. Thanks for the note, Thomas! -- Ben Okopnik


Non-ASCII characters and LG

Wed, 26 Sep 2001 11:28:04 -0700
Sándor Bárány ()

As frustrating as I find "quoted printable" or HTML attachments, they are ways that foreign character sets can survive to get to me. I'm pleased to say that since he is active on Debian mailing lists, some of whose archives do not ruin his name, I was able to rescue it from the Dread Question Mark Disease. The rest of our answer is from Mike Orr. -- Heather

thank you very much for your answer about apropos. The solution you sent works properly. I had myself something similiar; however I could not imagine there is no built-in possibility for my problem which I have overseen.

An OS can never give you all the commands you want, especially since they conflict with the commands someone else wants. What Unix gives you is a comprehensive set of basic commands and the building blocks to build higher-level custom commands. This is why shell scripts and aliases are so highly valued by Unix enthusiasts, because they give you the ability to make custom commands for anything the developers might have forgotten.

I crosschecked it again and my mailer inserts the proper headers: Content-Type: text/plain; charset=iso-8859-2

Content-Transfer-Encoding: 8bit

I find it really very pity you do attempt any use of i18n in your mailer. I am from Hungary, so I actually need the iso-8859-2 charcter code when I use my mother language for mails; however, my name is within the simple Western-Europe or ascii256 charset. If you US people insist on using us-ascii then ther are plenty of guys on the world who do not have any chance to see their name as in their personal documents. I have recently run some circles around locales and gnome (which I prefer to kde), and I have to tell you how much I was shocked by the fact how long way is to go till we reach to the point Windows95 already had. I have freefonts, ttfs, X fonts for several languages etc. but when I wanted to print out proper hungarian characters I had to redirect the StarOffice postscript output to file (was also forced to use elementary postscript fonts), and drive it through 'ogonkify'. A large number of Linux users can not live with us-ascii, so at a given point they are lost.

The problem of representing multiple languages is acute, and I strongly wish Linux was more advanced in that area. If editors and browsers fully supported Unicode seamlessly across the board, we would switch to it in an instant. However, 8-bit character sets continue to be better supported. The limitation is that only one 8-bit character set can be active at a time, meaning you can't properly display a document containing English and Russian and German unless one of the languages is ASCII-ified. This was a pain when I had Russian friends in Russia and Germany I sent e-mail to and typed up text documents for.

LG has just thrown its hands up in the air and taken the incorrect-but-easiest approach of using Latin-1 but pretending it's ASCII. Most of the non-English mail we get uses Latin-1 characters. I try to convert these to HTML entities when I see them, but I don't make a time-consuming effort of it. Compounding this is the fact that many of us use mutt as our mailreader, and mutt replaces non-ASCII characters with "?". Then if you save the message or forward it, mutt converts the placeholder "?" into real "?", and then the original character is completely lost. With Romance/Germanic languages we can usually guess what the original character was and substitute it back (because "ma?ana" is clearly "mañana", "K?ln" is "Köln", "Jos?" is "José", "Universit?t" must be "Universität" because "Universitöt", "Universitüt" and "Universitßt" don't exist, etc--unless you want to say "Universitöt" is slang for "dead university"!); however, with names from other languages we're at a total loss.

Perhaps someday we can come up with a more enlightened way to support multiple languages, but this is what we have now.

Last question: are you plan to publish on the Linux Gazette page this new Answer-Gang mail address? Or not publishing it is the proper way to avoid getting rid of off-topic questions :))

The linux-questions-only address is at the top of the Mailbag page and The Answer Gang index page, where we have always published it. The top of the 2-Cent Tips page still has the gazette address, but I've asked Heather to change it. In any case, I bounce everything to linux-questions-only that was misaddressed to gazette.

If you see anywhere else (besides in back issues) where the gazette address or the obsolete tag address is used, please let me know and we'll change it.

I thought about putting the address on the home page but decided against it, because people should at least have a look at what The Answer Gang is about before they find out there is a submission address.

The problem of off-topic questions was not caused by Gazette readers. It was caused by the fact that the tag address was published on many webpages with no reference to LG. So people would type their question into search engines, find the tag address, and send us questions, often without even realizing Linux Gazette existed. Our off-topic questions were easily 50% of the total. See the past several issues of The Back Page for the more amusing ones, and issues of The Answer Gang before that.

Since switching to the linux-questions-only address, our off-topic rate has dropped to near zero, and we are also seeing fewer Linux questions from people who don't even bother to read the FAQs and documentation first but just expect us to hold their hand. LG believes in helping those who help themselves.

-- Mike


Missed the toons

Fri, 14 Sep 2001 10:06:26 +0530
Sudhakar . A N ()

I miss the toons in your lates issue.

We miss them too. Shane Collinge has to concentrate on paid employment for a while, so HelpDex is on hiatus. Eric Kasten has his hands full doing whatever he's doing, so Tuxedo Tails is also taking a break.

Jon "Sir Flakey" Harsem is still going strong, so we have a new installment of Qubisms this month for your cartoon fix. It was missing last month because I, um, forgot to include it. Most Qubism cartoons are non-Linux but I'm including some of the funnier ones anyway.

I originally told Eric Kasten we wanted only Linux cartoons, but he said Linux is too specific a topic to come up with that many cartoons about, so I've been publishing non-Linux Tuxedo Tails panels too.

--Mike.


email with multiple POP3 accounts

Thu, 30 Aug 2001 11:33:54 +0800
Artemista - ()

Thanks to everyone who responded to my question. With everyone's advice, I was able to figure out a solution to the problem.

-- Artemista


Link fix needed: http://www.linuxgazette.com/issue70/tag/9.html

Sat, 01 Sep 2001 21:56:10 -0600
Alvin Austin ()

Hi Heather,

In the latest Linux Gazette online issue, the link to the "internet cafe" is set to that of "Password aging" instead of:

http://www.linuxgazette.com/issue70/tag/9.html

You will want to correct this.

Have a nice day,

Alvin Austin

Ooops! Sorry about that! As Mike noted elsewhere, my conversion script caught a bug last month, and I mostly managed to clean up after it, but obviously, I missed another one. -- Heather


This page edited and maintained by the Editors of Linux Gazette Copyright © 2001
Published in issue 71 of Linux Gazette October 2001
HTML script maintained by of Starshine Technical Services, http://www.starshine.org/

"Linux Gazette...making Linux just a little more fun!"


News Bytes

Contents:

Selected and formatted by and

Submitters, send your News Bytes items in PLAIN TEXT format. Other formats may be rejected without reading. You have been warned! A one- or two-paragraph summary plus URL gets you a better announcement than an entire press release.


 October 2001 Linux Journal

The October issue of Linux Journal is on newsstands now. This issue focuses on Engineering. Click here to view the table of contents, or here to subscribe.

All articles through December 1999 are available for public reading at http://www.linuxjournal.com/lj-issues/mags.html. Recent articles are available on-line for subscribers only at http://interactive.linuxjournal.com/.


Legislation and More Legislation

Behold the debut of a new News Bytes section.

This is the third month in a row that the legal landscape surrounding Linux users and programmers has been rapidly changing. We want to give adequate coverage to these changes--new laws and proposed laws--around the world. Since we have personal knowledge only of the US and Ireland, we'll need readers to what's happening in their countries. This is important because anything that gets enacted in one country is often held up as an example to encourage similar legislation in other countries.

For any new law, one must ask: Who is pushing it? What will they gain? Who will lose under it (re fines or jail time)? Why? Do the proponents have a secret agenda to use the law in ways the legislature didn't intend? Do they have a not-so-secret agenda to push for bigger laws after this one is passed and accepted by the public? What unintended effects will the law have that even its proponents did not predict? We can't answer all these, but hopefully we can start asking the questions.

Especially the last question. This section is partly an Ode to the Law of Unintended Effects, because there are so many of them recently.


LG reported in July and August about the unexpected fallout from the Digital Millenium Copyright Act (DMCA). Companies are using it to suppress criticism of their shoddy designs, prevent customers from protecting themselves from the effects of said shoddy designs, and even jail a foreign programmer for writing (in his home country) a program that is legal in his home country. Now that Dmitry is facing a possible sentance of 25 years, I guess a decline in corporate profits is more serious than armed robberies--even if the decline in profits is hypothetical or imagined. (Didja notice how in spite of Napster, Gnutella and DeCSS, the sales of CDs and DVDs continue to go nowhere but up?)

Foreign programmers like Alan Cox (#2 Linux kernel developer and former Usenix coordinator) are avoiding the US in order not to fall into the same trap Dmitry did. American programmers are looking for jobs elsewhere -- anywhere -- now that normal and necessary practices in security development and security certification are illegal. Not that there may be many places to go: the major proponents of the DMCA (the five biggest media-publishing and software-publishing conglomorates) are using the established US law as an example to push for similar laws in Canada, Europe and the FTAA (a possible future free-trade zone covering North and South America), saying: "See, they did it, so you should too."


In September, change went from "high gear" to "extremely high gear" and then into "overdrive". The Big 5 publishers came back with an even sweeter proposal, the son of DMCA. Aiming to plug the "loopholes" in the DMCA (meaning the last bit of fair use the DMCA allows), the Security Systems Standards and Certification Act (SSSCA) [draft text] [another draft] would make it illegal to "manufacture, import, offer to the public, provide or otherwise traffic in any interactive digital device that does not include and utilize certified security technologies that adhere to the security systems standards adopted under section 104."

"Security systems standards" means software that enforces digital copyrights. Remember CRPM, the aborted effort to put non-bypassable rights management into the firmware of all new IDE hard drives? That was scrapped because too many customers would refuse to buy such products. But SSSCA would make this or the equivalent mandatory.

Linux Weekly News writes, "The definition of a 'digital device' is just as broad as it sounds - essentially, anything--hardware or software--that is capable of moving and storing bits. In particular, a computer running Linux is certainly such a digital device, as is Linux itself or any of a number of other free programs." Free-software advocates are concerned, because is it even possible for Linux to be compliant? Linus could implement some rights-management code in the kernel, but because it's open source, any programmer could just comment it out. And the companies would presumably want to keep their (shoddy?) rights algorithm secret, so it would be available only in binary form. Would they even make a Linux version? If they did, would Linus have to link a proprietary, binary-only library into the standard kernel and change Linux's license to allow and mandate this? Would the kernel have a new module "digirights.o" with the help text, "If you are outside the United States, choose 'N' for maximum flexibility, reliability, speed and security. If you are inside the US, be aware that choosing 'N' may be a felony, and you should consult a lawyer before proceeding."

Another problem is that the technical standard is to be determined by "representatives of interactive digital device manufacturers and representatives of copyright owners". What about representatives of the public? The constitutional right of copyright is a balance between the author's interests (payment) and the public's interests (the "progress of science and useful arts" by having everything become public domain after a limited time, and fair-use rights in the meantime). But this law is one-sided in favor not even of the authors, but of the big publishing houses.

There is also a certain antitrust exemption in the bill.

One concession to fair use remains: TV time-shifting. People will be allowed to record a TV show if it's an "over-the-air broadcast, non-premium cable channel or non-premium satellite channel". Recording a Showtime movie would become illegal since it's on a premium cable channel. Note that there's no provision for radio, webcasting or future technologies, so there would be no fair use at all for those.

The SSSCA is not law yet. In fact, as of early September it had not even been introduced in Congress, just debated informally. More happened later, but let's keep things chronological....


On September 11, the tragedy heard round the world. This has been well reported elsewhere, so I will stick to the issues relating to Linux. Suddenly, crypto back doors and crypto export limitations are fashionable again. Congress is falling over itself trying to pass anti-terrorism legislation as quickly as possible. Some of this legislation is good and necessary. But lobbying groups and government agencies are finding a rare window of opportunity to sneak long-desired unrelated topics into the package, and they are not shy about exploiting it. It's a lobbyist's dream as Congress is in a spending mood and eager to pass any legislation that purports to hinder terrorism, without enough time to evaluate whether the actual effects will be good or bad.

Of course, there are the usual arguments against encryption back doors:

Exactly one week after the terror attacks, the Nimda worm/virus appeared, the son of Code Red. The Justice Department included in its Anti-Terrorism Act language that would define hackers, virus-writers and web site defacers as "terrorists", eligible for life imprisonment without parole. "Cracking a computer for the purpose of obtaining anything of value, or to deliberately cause damage" would carry the same penalties as assassinating a public official or dropping a chemical weapon. The law would be retroactive to the beginning of time, so even crimes committed long ago could be tried under it. Fortunately for Kevin Mitnick, he's already received his sentance. But those who break into a grocery store's web site and order a pack of gum for free had better watch out. And those who provide "'advice or assistance' to cyber crooks, or harbor or conceal a computer intruder" would receive the same punishment as the intruders themselves. "DNA samples would be collected from hackers upon conviction, and retroactively from those currently in custody or under federal supervision. The samples would go into the federal database that currently catalogs murderers and kidnappers."

What happens if you cross an Anti-Terrorism Act with a Digital Millenium Copyright Act? Answer: Dmitry goes to prison for life. No, that hasn't been proposed. But watch out for that definition of "hacking" and see what exactly it includes, and whether it expands later. Remember the law of Unintended Effects.

Larry Ellison, the head of Oracle, is calling for national ID cards. This may sound like merely the musings of a concerned citizen until you remember that an ID-card system needs a database, and why not an Oracle database? Ellison is offering to give the government the software for free, but still, what a PR bonanza for Oracle it would be. (Like when Microsoft "gives" software to schools. Of course, nowadays it "sells" software to schools....) Regarding identity cards themselves this report looks at countries that use them and countries that don't use them, and notes the differences between what each country originially intended its card for vs how it's being used now. (Again, the Law of Unintended Effects.)

There is one bright side: Congress is considering splitting up the omnibus Anti-Terrorism bill. That would allow it to pass the most urgent portions right away, but hold off on the more controversial measures until they can ascertain which ones would cause more harm than good.


In late September, the SSSCA was introduced in the Senate. It has a long way to go before it becomes law, since it has not even been introduced in the House yet. Most are predicting it has too many critics to pass this year, but portions of it could crop up in future years.

Linux Journal's Don Marti chided Michael Eisner, the Charman and CEO of the Walt Disney Company, for planning a trip to Washington, DC, to "close the deal on a computer censorship bill, the SSSCA, you're buying from Congress." He also chided Senator Fritz Hollings (D-SC) under the headline, "Senator Hollings Cheaper Than We Thought", saying that Eisner had paid Hollings $18,500 to get the bill introduced. (And not the $25,000 LJ had previously reported.) Of course, the payment was in the form of cumulative campaign contributions, not a direct bill payment (pun intended).

The Register notes in "Copy-Control Senator Sleeps While Fair-Use Rights Burn" that the Big 5 media companies are among the top 20 contributors to Hollings' election campaigns: AOL Time Warner, the Murdoch-owned News Corporation, Viacom's CBS, the National Association of Broadacsters, and Walt Disney Company. If you type "senator hollings campaign contributions disney" into Yahoo, several other articles come up, including this one. (Yes, you can try this at home. Type "senator <NAME> campaign contributions" and see what comes up for your favorite Congresscritter. Or "representative <NAME>" for members of the House.)

Here's an article that looks at SSSCA from the manufacturer's standpoint: Bill Could Force Copy Control On IT Firms. It says the SSSCA "could slow the development of the technologies it seeks to regulate by shifting the attention of the industry from product development to lobbying." One attorney comments, "Telling us what systems to pay for and implement to protect someone else's property doesn't make sense."

Another Register article says the SSSCA "would close all the irritating little loopholes in the DMCA right around the necks of consumers, where, the industry reckons, the pressure rightly belongs." And, "Conveniently, and by design, the words 'fair use' appear nowhere in the draft. The industry lobbyists never liked that troublesome phrase in the DMCA, so now it's gone." The article also points out that the SSSCA does not require new complient hardware to be backward-compatible with older hardware, meaning another round of buying the same content again.


The role of the Electronic Frontier Foundation (EFF) emerged as a topic in activists' discussions. Many people think of the EFF as a lobbying organization, but its mission is actually to defend individuals who have been unjustly accused. Taking on full-scale lobbying of Congresscritters would require significant changes to EFF's structure, tarnish its reputation among those who raise their noses at "lobbyists", place the organization in a different tax category, and distract it from defending individuals.

Thus, the free-software and "free Dmitry" groups are debating whether they should start a lobbying organization themselves. Of course, one's first knee-jerk reaction is to stay as far the h*ll away from Washington as possible, but if we don't do it, who will? Of course, it would mean doing some distasteful things. Like (gasp) making campaign contributions to influence a Congresscritter's votes. Is the free-software community ready to sponsor a PAC? (PAC = Political-Action Committee, a fancy term for "lobbying group".) Even though freeniks have some of the highest noses and loudest sneers against "lobbying scum"? Some are considering it, thinking it's the only way make a dent in the rapidly-accelerating onslaught against our rights. Obviously it's something that it will take a long time to come to consensus on.


There is another bright side, as pointed out in the IT article. The media companies should watch what they wish for because they just might get it. Perhaps the Law of Unintended Effects will end up applying to them. Especially if enough people decide they can do without the Big 5's content.

Or if artists start giving away all their music for free. That would generate more fans at shows, and bands receive much more money from one concert patron ($5-10, plus $10 if she buys a T-shirt) than they do from one CD purchase (less than $1). And if she buys a CD at a show, they both win: she gets a discounted price (often $10), and the band get a few dollars rather than the 25 cents they would get from a retail sale.

Then we would see corporate profits drop.


In conclusion, the DMCA was passed and nobody noticed. (A few people like Richard Stallman sounded the alarm, but everybody said it wouldn't get that bad.) Now when it's too late, we are seeing the effects. We're also seeing DMCA-like laws pushed in countries we thought were "safe". Then the publishers pull a rabbit out of their hat with another law, and it doesn't take a rocket scientist to see that it will also turn out to be more powerful than it appears when it's passed (if it's passed), just like the DMCA.

This, coupled with the crypto back door and hacking-considered-terrorism proposals and others, foreshadow a society fifty years from now vastly different than now, where everything is pay-per-view, fair use is forgotten, all available computer hardware enforces this, and Linux has been illegal for so long that nobody remembers what it was. But the biggest companies will still have familiar names--AOL Time Warner, Walt Disney, Microsoft. The laws give a competitive advantage to the companies that were dominant at the time of the laws' adoption, since they can use the laws to sue everybody else out of existence. (Why else do you think they pushed so heavily for the laws in the first place?) Perhaps many people in today's computer field will drop out in disgust and switch to other professions, and shun e-mail and the phone in favor of face-to-face activities. Farfetched? Perhaps, but we've learned and not to trust the CEOs and politicos any farther than we can throw them, and to expect the worst because it will turn out worse than that.

Of course, one wonders whether the needs of the publishers for strong encryption and the needs of the FBI for weak encryption are on a collision course. We've already seen that the needs of the FBI (to catch bad guys) and the needs of e-commerce (to promote a healthy economy) are opposite: that's why the Clinton administration weakened crypto export laws, and why the FBI is now pushing back.


Other items of interest

"Anticircumvention Rules: Threat to Science" (Science magazine) argues that the DMCA is a threat to all scientists, not just those in computer security and encryption research. "Virtually all computer scientists, as well as many other scientists with some programming skills, find it necessary on occasion to reverse engineer computer programs. Sometimes they have to bypass an authentication procedure or some other technical measure in order to find out how the program works, how to fix it, or how to adapt it in some way. The act of bypassing the authentication procedure or other technical measure, as well as the making of a tool to aid the reverse engineering process, may violate the DMCA. Although the DMCA also has an exception for reverse engineering of a program, it too is narrow. It only applies if the sole purpose of the reverse engineering is to achieve program-to-program interoperability and if reverse engineering is necessary to do so. Trying to fix a bug or understand the underlying algorithm does not qualify. Information even incidentally learned in the course of a privileged reverse engineering process cannot be divulged to any other person except for the sole purposes of enabling program-to-program interoperability." The article also speculates about a pharmaceutical company that "produces data to prove that a new drug is safe but technically protects it so that only certain tests can be performed on the data, all of which support the safety claim. A scientist who doubted the safety claim and tried to process the data by additional tests would violate the DMCA if he or she bypassed the access control system restricting use of the data."

Lawrence Lessig, who wrote _Code and Other Laws of Cyberspace_, is interviewed by LWN's Dennis Tenney. He gives his perspective on the DMCA, Dmitry Sklyarov's case, Hailstorm, international jurisdiction, etc.

Background on the DeCSS case.

A Slashdot post that describes some of the lesser-known provisions of the DMCA.

Phil Zimmerman, creator of PGP encryption, explains how he was misrepresented by the Washington Post. The Post reported that he was "overwhelmed with feelings of guilt" over the fact that the September 11th terrorists may have used PGP in planning their attack. Zimmerman reiterates that he thinks the public having access to strong encryption without back doors is a good idea, and that PGP is a good tool for human rights around the world. He also insists he will not allow any back doors in PGP.


Linux Links


Linux Focus
The following articles are in the September-October issue of the multilingual ezine Linux Focus.

In case you missed some of Linux Journal's technical web articles over the past few months here are some links to System Administration articles by Marcel Gagné

Linux Journal also has an online Review of the book Linux Administration: A Beginner's Guide, Second Edition.

Linux Magazine have an article on MySQL performance tuning. Much of the information could be applied to any SQL database.

The Duke of URL has

The Linux Review have taken a look at the new KDE 2.2 and its applications. The review points out missing features that allegedly make the corresponding Windows and Macintosh applications superior (even MS Outlook!). There is also a follow up. Courtesy LWN.

Could DMCA be outflanked by new cosmogeny and quest for meaning of life ;-).

There is an interview with the creator of MenuetOS over at OS News. MenuetOS is a small assembly-language OS that fits on a floppy with room for a few applications. The video driver has 16.7 million colours.

Some links courtesy of Slashdot:

In industry bad news, Linux Weekly News have reported that Great Bridge has closed its doors. Great Bridge was the company that brought LG the article The Opening of the Field: PostgreSQL's Multi-Version Concurrency Control.


Upcoming conferences and events

Listings courtesy Linux Journal. See LJ's Events page for the latest goings-on.


Cluster 2001
October 8-11, 2001
Newport Beach, CA
http://www.cacr.caltech.edu/cluster2001/

Linux Lunacy
Co-Produced by Linux Journal and Geek Cruises

October 21-28, 2001
Eastern Caribbean
http://www.geekcruises.com

LinuxWorld Conference & Expo
October 30 - November 1, 2001
Frankfurt, Germany
http://www.linuxworldexpo.de

5th Annual Linux Showcase & Conference
November 6-10, 2001
Oakland, CA
http://www.linuxshowcase.org/

Strictly e-Business Solutions Expo
November 7-8, 2001
Houston, TX
http://www.strictlyebusinessexpo.com

LINUX Business Expo
Co-located with COMDEX
November 12-16, 2001
Las Vegas, NV
http://www.linuxbusinessexpo.com

15th Systems Administration Conference/LISA 2001
December 2-7, 2001
San Diego, CA
http://www.usenix.org/events/lisa2001


News in General


 Python10 conference

The Tenth International Python Conference (Python 10) will be held on February 4-7, 2002, at the Hilton Alexandria Mark Centre in Alexandria, Virginia. The Call for Papers for the Refereed Paper Track, and the Call for Tutorials can be found at www.python10.org/p10-callpapers.html, and www.python10.org/p10-calltutorials.html, respectively. The deadline for submitting a paper to the Refereed Paper Track is Monday, October 8, 2001. The deadline for submitting a proposal for Tutorials Day is Monday, October 1, 2001.


 LLNL Adds Linux Cluster Supercomputing Power to ASCI Project

SGI Federal, a subsidiary of SGI, has teamed up with Linux NetworX to win a bid to build three Parallel Capacity Resource (PCR) Linux cluster computing systems totalling 472 Pentium 4 processors for the National Nuclear Security Administration's Accelerated Strategic Computing Initiative (ASCI). ASCI is a program to reach 100-trillion calculations per second by 2005 that will help scientists to maintain the safety and reliability of the U.S. nuclear stockpile by simulating the aging and operation of nuclear weapons. With a theoretical peak performance of 857 gigaFLOP/s, the largest of the three systems with 252 Pentium 4 processors, named PCR P4A, will be one the fastest Linux clusters ever built.


 Petroleum Penguins

Landmark Graphics Corp., a wholly owned business unit of Halliburton Company, today announced plans to offer its full suite of integrated UNIX exploration and production applications on a range of Linux platforms with rollout beginning in the fourth quarter of 2001. This marks the most significant commitment to date by a major technology provider in the oil and gas industry to support the "open source" Linux operating system. Compaq, Dell, EMC, IBM, Intel and Network Appliance are working with Landmark to offer a broad range of optimized Linux solutions, including workstations, servers and storage.


Distro News


 Debian

There are a lot of orphaned (102) and up-for-adoption (35) packages out there. Some of the packages include kicq, knews, mcvert (Mac to Unix file converter) and several others. A list of packages is found here.


Adam Di Carlo announced that version 3.0.14 of the boot floppies are available for testing for powerpc and i386. Hammer on them and send reports, comments or praise to [email protected]. Original story.


Debian Security is crucial to users and should be managed properly. Recently, to help improve the situation, Joey Hess has asked for a Security Secretary, who will help the Debian Security Team doing their work.

Reports taken from Debian Weekly News.


 SuSE

From the end of August, SuSE Linux Enterprise Server 7 will be available for Intel's 32-bit architecture (x86), Intel's 64-bit architecture (Itanium processor family), and IBM's mainframe platform S/390. Versions for IBM's iSeries, pSeries, and zSeries will follow in late autumn. Included in the purchase price, are maintenance services that make sure that SuSE Linux Enterprise Server 7 is always up-to-date, stable, and tested. SuSE regularly informs users by e-mail and makes the respective patches, fixes, and updates available via FTP server. For more information please refer to http://www.suse.de/en/sles/


SuSE Linux have also announced that SuSE Linux Database Server combines the operating system platform of SuSE Linux Enterprise Server with IBM's DB2 Database to form a complete solution for professional users. In mid September, SuSE Linux will present an updated version of the solution package.


Software and Product Announcements


 New CPCI SBC from MEN Micro

MEN Micro have released a new CompactPCI single board computer (SBC). The SBC comes in three versions, and each version includes a 300 MHz PowerPC XPC8245. The D3, as the new SBC is designated, is a one-slot 6U CompactPCI board. In CompactPCI systems it operates as a master system-slot board, but in embedded applications it can also operate as a standalone processing unit without a bus connection. As a computer, the D3 comes with up to 256K of DRAM in a SODIMM slot, two megabytes (MB) of flash memory and an ATA-compatible CompactFlash site, in addition to numerous other I/O features. The D3 can run either the VxWorks or Linux operating systems. For more information on the D3 including a data sheet, go to www.men.de/products/press.


 Rackspace Named Best Dedicated Host

Rackspace, who hosts more than 2,500 Linux servers, has earned the title of "Best Dedicated Host", as judged by the editors of Web Hosting Magazine, because of their dedication to customer service.


 SAIR Linux and GNU Certification

Recently, to assist in promoting the Linux+ certification effort, SAIR Linux and GNU Certification has released a version of its Fundamentals course-ware, which doubles as preparation course-ware for CompTIA's Linux+ Certification exam. SAIR Linux and GNU was contacted by CompTIAŽ to aid in the development of CompTIA's Linux+ Certification exam. The course title is SAIR Linux and GNU Fundamentals/Linux+.


 Linux Based Ethernet Compatible Set Top Box

Media Technology have launched their new product, the VT900 Set Top Box. The VT900 enables Ethernet 10/100 data streams to be converted to composite analog RF data streams or digital S-Video data streams compatible with all standard TV sets. Over 250 channels of various forms of TV-format data have been successfully tested with the VT900. Implementing Linux, the VT900 incorporates a full browser, and supports all plug-ins. Partnerships have been established with both Century Embedded Software Inc., and Enreach Technology Inc, to further develop application software. The VT900 is designed using the National Semiconductor Geode processor in conjunction with the Sigma Design EM8400 MPEG Decoder and the Macphyter Ethernet adapter. Optionally available are DVD Player, CDRW, Floppy and standard IDE Hardware.


 Team ASA Announces NPWR SBC up-grade with Dual Gigabit Ethernet Ports

Team ASA's NPWR is a Single Board Computer (SBC) designed for manufacturers and OEMs in the Network Attached Storage (NAS), RAID, and Personal Server marketplaces. It is now available with dual Gigabit Ethernet ports. The NPWR is powered by the Intel XScale processor, the XScale is a RISC CPU with clock rates reaching as high as 733 MHz. NPWR's standard configuration includes 160 Mbytes per Second (LVD) SCSI port, 8 Mbytes of FLASH ROM, 128 Mbytes of SDRAM and a Gigabit Ethernet port.


 DocPro DocBook Tool Set

Command Prompt, Inc. is pleased to announce DocPro, the "professional DocBook tool set". DocPro is a compilation of tools designed to allow technical writers to effectively process their DocBook SGML and XML layout. DocBook itself is a powerful markup language. However, the tools are painful to compile, configure and work with. Command Prompt, Inc. has eliminated the problems associated with the integration of these tools into a production environment. DocPro comes in Basic and Deluxe versions, and should work with all RedHat 6.2 and later compatible distributions of Linux.


 Tarantella Enterprise 3 Starter for Linux

Tarantella, Inc. has announced the availability of Tarantella Enterprise 3 Starter for Linux software. The product makes it possible to publish Windows, Web, Java, AS/400, Linux and UNIX applications securely to client devices anywhere. It can be used for a wide range of tasks, such as remote system administration or accessing company applications and services from home.


 Embedded Open Motif

Integrated Computer Solutions has announced a version of Open Motif targeted at embedded and handheld devices with limited displays, memory, and processing power. Embedded Open Motif has been ported to the Compaq IPAQ and the Agenda VR3 from Agenda Computing. Both source code and binary packages are available for free download from the MotifZone. Get more information online at: http://www.motifzone.net/forum/forum.php?forum_id=140


 WAP Opera

Opera Software have announced that future versions of its browser will support the new and improved Wireless Application Protocol (WAP) 2.0 standard.


Opera Software have also opened the revamped MyOpera community and released the second edition of their popular Opera Composer, inviting users to join an Opera community or create their own. In this new version, users can customise their own Web browser for the Linux platform as well as for Windows,


 Alabanza

Alabanza has launched version 4.1 of of its Automated Web Hosting Software Suite, which was originally built on and still runs on the Linux operating system. The latest version of the software suite includes a new Web Site Builder tool it acquired from OnNet Web Hosting. Version 4.1 automates administrative Web hosting tasks, empowers users to update sites, provides for complete security and furnishes electronic commerce services for small businesses. Alabanza's Automated Web Hosting Software Suite 4.1 is the most proven, reliable and secure solution on the market for hundreds of Web designers and developers, systems integrators, Internet service providers and telecommunications carriers. It allows end users to automate administrative tasks, manage content, and update Web sites with a significant decrease in time and costs; all within a secure environment.


 BrainTAGS

BrainT@GS has released NetRelay. This software-tool automates processes between web client, server and databases. This includes automatic record creation, deletion, display and up-date and integration of a template-engine. The intelligent and structured architecture of NetRelay makes the development of dynamic web applications more transparent and structured. NetRelay creates a clear separation between logic and presentation and also generates automatic XML documents, enabling easy data-transfer. NetRelay is database independent. NetRelay runs on any server platform supporting the JDK, and has been tested on Linux.


Copyright © 2001, Michael Conry and the Editors of .
Copying license http://www.linuxgazette.com/copying.html
Published in Issue 71 of Linux Gazette, October 2001

(?) The Answer Gang (!)


By Jim Dennis, Ben Okopnik, Dan Wilder, Breen, Chris, and the Gang, the Editors of Linux Gazette... and You!
Send questions (or interesting answers) to

There is no guarantee that your questions here will ever be answered. Readers at confidential sites must provide permission to publish. However, you can be published anonymously - just let us know!


Contents:

¶: Greetings From Heather Stern
(?)Q: avoid getting answers from apropos in the man sections 3 and 3x
(?)"crypt" function in Linux
(?)I think this would be a common problem at least is has been for me --or--
Dependency Hell
(?)Is This a Good Book for Linux Programming?
(?)What ISPs Do We Use for Linux
(?)How to let the world find your Linux Server when using DHCP
(?)trouble w/ dual boot
(?)Any good resources on laptop hardware support? --or--
HOWTO find a good laptop

(¶) Greetings from Heather Stern

Ouch.

The world trade center in shambles. The financial community is still mostly in shock. The airline industry is rightfully quite horrified. I know I'm horrified...

What can we, members of the free software community, do?

I know a lot of sites have put up banners linking to various helpful organizations, the Red Cross, funds for the families of all the emergency personnel killed, and so on. So much in fact, that I wonder how many charities will go short shrift of donations, clothes, and other things, simply because this one presently has everyone's attention.

But that's what we do as people. As a community we can do a lot more. Slashdot did great on keeping us all in tune with the news, when the routers in front of almost every major news service were going into meltdown. People used IRC and websites to find out if friends were alive and well, I saw wikis, I saw email lists briefly stop talking about the topic of the moment and reserve the day for traffic about who was okay. Now this didn't just mean wondering whether anybody died in New York. For instance, a friendly soul from the GNOME Usability Project was trapped in China for 6 days longer than he expected... making it to our user group meeting just in time, I might add, but I think it probably dampened his enthusiasm for our chinese food.

We're an international community, and now an international problem that has existed for a long time has been made more obvious. These people that took these planes used little that was unavailable to Cro Magnon Man. I'll update them to the Bronze Age because they found a cheat sheet for how to not be followed - but we're still talking tribal hunters, not 21st century "agents" from The Matrix.

Yet there are these pushes to "wiretap" email. (See the Crypto-Gram Newsletter, http://www.counterpane.com/crypto-gram-109a.html for some details.) The ultra-protectionism of Big Corporate copyrights continues (you think the Digital Millenium Copyright Act, already passed and being enforced, is bad? Look at the bill "SSSCA" up for attention. According to the EFF's Cindy Cohn it makes the DMCA "look like the Bill Of Rights".) while frankly, my ability as a real individual who writes about one tune every 2 years, lyrics a little more often, and at least one article a month, to continue to enforce my OWN copyrights and fair use rights under the US Code, Title 17 (http://www4.law.cornell.edu/uscode/17/index.html) continues straight into the gutter. My expectation of safety when I visit a foreign country obviously won't be based on the idea that I was an invited speaker -- as far as I know, anybody who was trapped in another city because all flights were grounded has gotten home now, even the ones who took a taxi From Chicago to Los Angeles -- but Dmitry Sklyarov, a Russian citizen, continues to live trapped in the USA because eBooks can't be sold in Russia unless you can make a backup of them, and he agreed to TALK about how the encryption works on US soil.

NOW I'm terrified.

Of course most of my email lives a very public life already. But let's face it, a translucent dime store postcard written on in big black marker has more privacy than the average internet Joe. It's not a federal felony to hassle a small town ISP because they don't want to let you wiretap all of their customers just because you have a warrant on one of them. (We'll leave out whether the "up to something" they might be up to is about real life-and-death matters or merely about someone wanting to play Mom for us.) It's not a federal crime to impersonate being someone important so that your spam gets into a victim's box. Hey, I may dislike spam a great deal, but it's just a delete button, okay? He's said his piece and I ignore it. We paint over graffiti on the walls of small towns, no attention, no fanfare, and eventually the spams die. End of story.

Soon, however, it may be a federal crime -- penalty, to lose most of your rights of US citizenship forever -- to deface a website. HELLO real world! This is about equivalent to "joyriding". Give 'em some community service and get on with life. Goodness knows what level of punishment they have in mind for someone who believes that mail containing things about money matters really ought to be in an envelope that can't be steamed open, even in the figurative sense of cyberspace. (If you don't use PGP or GnuPG already, establish the habit now. Free interoperable clients for MSwin and Mac: http://www.pgp.com/products/freeware/default.asp) Or that we have a reasonable expectation of privacy and freedom to assemble as a group for any other reason. Or that the business transactions of any US company are none of any other company's or country's direct business, unless some sort of model of trust exists between them. Join the Electronic Frontier Foundation and keep up on other resources about what is going on. As a group we have a better chance. (There are other privacy related groups out there too. Cato.org, the American Civil Liberties Union, and Europeans might consider checking out the Justis database, http://www.justis.com/database/european_law.html. I'm sorry I can't read other languages or surely I'd have more pointers...)

The electronic 'zines I'm subscribed to were singing the praises of the IT staff who arranged for businesses to go onward regardless of the chaos. They're only just starting to notice the drastic legislation that's trying to come down the pipe on a wave of patriotism, duty, and budget-grubbing. I work with and know a lot of sysadmins. I can tell you that a lot of sysadmins right now don't like the idea of being put in a tight spot: as a cop, with none of the legal defenses a cop has for doing his job; as a carrier of bits, with none of the legal defenses of a telphony Common Carrier for the fact that we are not the origin of any of this information; as an implementor of company policy, and a professional with special skills, but without the defense of "client privilege" that other professions enjoy.

A number of legislators are quite up in arms over the idea that they are being asked to vote on these matters without enough time to read all the horrid little details. However, some seem to want this extra time so they have a chance to draft their own pet departments, see http://dailynews.yahoo.com/htx/ap/20010920/us/attacks_terrorism_laws_3.html. Call your reps now and make sure that whatever does finally get drafted actually defends and supports you. I'm sad to say that email probably isn't enough -- you can try it, but they get a ton, and it carries little emotional power. Use a phone and talk to these people.

While a proposed bill isn't exactly "closed source" it is pretty much what something huge like OpenOffice or the linux kernel is to someone uninitiated to the wizardry of C and perhaps even deeply experienced in the same. Of course in our scope we have all sorts of utilities to help us manage large projects and sort through things. So what I'd love to see is some sort of "pretty print" style parser that goes over proposed bills and exposes the described crimes, regulations, penalties and so on to a bit of serious debugging. The "sources" are readable by anyone on THOMAS, http://thomas.loc.gov/; although goodness knows if those are up to date with what is being argued on the Congress floor, it's a start. I'm sure somebody out there can give it a shot!

On a somewhat more local note, we had many more threads than this, in fact I am amazed at the percentage of incoming questions that we answered. But I just got all boiled up and had to let off the above rant. On the plus side my scripts are doing better by far than last month. So I have picked some highly juicy ones and hope you'll forgive me the short list. We have new Biographies for the Answer Gang, too, so you can get a sense of who answers your questions here.


(?) Q: avoid getting answers from apropos in the man sections 3 and 3x

From Sándor Bárány

Answered By Mike Orr

Dear Answer Gang,
I am looking for a way to avoid getting answers to my apropos queries from the man sections 3 and 3x (ie I want to see only command names and no APIs). How can I do that without statically removing those man sections?
Regards,
Sándor Bárány
(!) [Mike] If you want to see only a certain section, you can pass that as the second argument to "man". For instance, "crontab" has two pages. "man 5 crontab" shows the file format, and "man 1 crontab" (or "man 8 crontab" on some systems) shows the command.
Apropos doesn't have any options, but man can be called as:

man -S 1:5:8 MyCommand
man --sections=1:5:8 MyCommand
to make it search only certain sections. In this case, it will display the first file it finds.
The easiest way to do what you want would be to have a shell script or function that greps the output of "apropos" to remove the unwanted lines:

#!/bin/sh
apropos $* | fgrep -v '(3)
(3X)'
Or if you like regular expressions:

#!/bin/sh
apropos $* | egrep -v '\((3|3X)\)'

(?) "crypt" function in Linux

From Ben Okopnik

Answered By

Just a little while ago, I needed to use the "crypt" program, so well-known in other Unices, to encode a text file (for those of you unfamiliar with it, it encrypts the contents of a file using a password that you supply. A fairly useful little utility when you want just a bit of added security on a publicly-readable file.) Imagine my surprise when I found that Linux does not have one! Once again, it's Perl to the rescue.
This version follows the syntax of the original "crypt", although I'm certain that the algorithm is different. The encryption and the decryption are symmetric, meaning that the same syntax is used for both (with the obvious exception of the relevant filenames):

# This encrypts the contents of "mysecret.txt" using "iAMw0tIam" as the
# password and saves the results to "mysecret.encrypted".
crypt iAMw0tIam < mysecret.txt > mysecret.encrypted

# This prints out the decrypted contents of "mysecret.encrypted" to the
# screen.
crypt iAMw0tIam < mysecret.encrypted

# This decrypts the contents of "mysecret.encrypted" and writes the results
# to "mysecret.decrypted".
crypt iAMw0tIam < mysecret.encrypted > mysecret.decrypted
Long passwords are preferable to short ones for better security; "crypt" accepts them without a problem, provided that any password containing spaces or other "weird characters" is quoted (preferably in single quotes).

crypt 'Praeterea, censeo Carthaginem esse delendam.' < file > file.enc
As always, bug reports, comments, and piles of diamonds are welcome. :)

See attached crypt.perl.txt

Ben Okopnik

(?) Dependency Hell

From Andrew

Answered By Thomas Adams, Dan Wilder, Heather Stern

(?) Hello Gang,

Hope you don't minding me milking some knowledge from you. One thing that has been bugging me for a while now is this.

I am running Redhat 6.1 with a recompiled kernel (2.2.19)..

This is the thing though. There are given programs that i may/do want to install that need different libraries for them to work. Most of my upgrades have been via rpm -U scenario (easy to keep track of what is on my system).

I need to install gcc which when i do the following i get this

[root@echelon /root]# rpm -ivh gcc-2.96-54.i386.rpm
error: failed dependencies:
        cpp =3D 2.96 is needed by gcc-2.96-54

so then i do this

[root@echelon /root]# rpm -q cpp
cpp-1.1.2-24

so i better upgrade

[root@echelon /root]# rpm -U cpp-2.96-85.i386.rpm
error: failed dependencies:
        libc.so.6(GLIBC_2.2)   is needed by cpp-2.96-85
        cpp =3D 1.1.2 is needed by egcs-1.1.2-30
        cpp =3D 1.1.2 is needed by egcs-objc-1.1.2-30

Mmmm i know GLIBC is pretty important so i get the version above & do the following

[root@echelon /root]# rpm -q glibc
glibc-2.1.3-22

so ok lets upgrade this (or at least try to)

[root@echelon /root]# rpm -U glibc-2.2-12.i386.rpm
error: failed dependencies:
        glibc-common =3D 2.2 is needed by glibc-2.2-12
        glibc > 2.1.3 conflicts with db3-3.1.17-4.6x
        glibc > 2.1.3 conflicts with rpm-4.0-6x
        libdb.so.2 is needed by enlightenment-conf-0.15-9
        libdb.so.2 is needed by pan-0.9.1-0_helix_1
        libdb.so.2 is needed by ggv-0.95-0_helix_1
        libdb.so.2 is needed by pygnome-1.0.53-0_helix_3
        [ . . . about 70 more complaints . . . ]
        libdb.so.3(GLIBC_2.1) is needed by perl-5.00503-6
        libdb.so.3(GLIBC_2.1) is needed by pam-0.72-20.6.x
        libdb.so.3(GLIBC_2.1) is needed by php-3.0.18-1.6.x
        libdb.so.3(GLIBC_2.1) is needed by sendmail-8.11.0-1
        libdb.so.3(GLIBC_2.1) is needed by openldap-1.2.9-6

Do you see wehat i am getting at

How would you get around these issues it can become rather frustrating

Any advice on this would be great like always

Thanx guys n girls

Regards

Andrew

(!) [Thomas] Hi Andrew,
Yuck!! You have managed to expose one of the more annoying features that the RPM format brings....version dependant files.
Since every package (or nearly every) is linked to another, you can imagine just how one package may be needed by another.
To try and get arounf your problem, you can specify to install an RPM file without looking for it's dependencies, thus:

rpm -i --nodeps ./rpmfile-version-3.rpm
But, one caveat with this, is that if you don't have/install the dependencies, then the program might not work.
Hope That Helps
(!) [Dan] It is a common problem. The common solution is to upgrade the installation using the upgrade method provided by the distribution. It may be time for you to upgrade across-the-board to Redhat 7.1.
It is possible to upgrade a distribution piecemeal, but it becomes more difficult (as you have observed) as the number of dependencies increases.
The alternative is going off-distribution and building the specific things you need from source, one at a time. This is more often not worth the effort.
(!) [Heather] Heh. Jim calls this "dependency hell". Every distro has it. Debian is pretty good about reducing the number of parts in the puzzle -- about the time you're looking at upgrading glibc, they call it the next version name, and a lot of people bust their butts to make the upgrade smooth. Of course, unless you're using LibraNet or something, the install is a bit rocky...
For staying with an older distro a bit longer (hey, it's not crashing, why change it much, right?) my common solution is to remove the offending rpms, use alien (a perl script) to transform deb files from the equivalent Debian variant, and then use those to provide the libraries and so on, that just my app needs. I've used this trick to introduce lynx-ssl to a number of systems that otherwise only come with a non-SSL version, often a bit old.
Nonetheless, I agree with Dan -- once you've decided to upgrade glibc, it's time to take your upgrade seriously, and make a new round of it. Distros vary widely as to whether it's safer to upgrade or to just install anew; with a good backup of all your personal files (don't forget odd things like any tweaks you made to config files in /etc/ or /usr/lib, notes about hardware you have and need support for, etc.) you can try an upgrade, and if it bombs, then install fresh.

(?) Is This a Good Book for Linux Programming?

From Chris Gianakopoulos

Answered By John Karns, Faber Fedor

(?) Hello Gang, I've mentioned that I am working on an embedded project that will use Linux as its kernel. As a result, I am learning to write cool software for the Linux platform.

The type of stuff that I have to do will be fork()s and exec()s (the "s" indicates lots of fork() and exec() invocations), IPC stuff, signals (I know -- that's IPC stuff, too). and pipes. I know that there will be slight differences (for example, the spawn() function), but now for the question.

There are lots of good guides (and of course, the man pages). I am also presently reading a book entitled "Advanced Programming in the Unix Environment" by Stevens.

Will that Stevens book lead me astray? It really is giving me lots of good insight (what other insight could there be?), so I hope that you tell me that it is good reading for learning to create complex software systems in Linux.

Of course, I will read the man pages and guides, and I expect that some header file may be in different places (I saw slight differences for network programming).

(!) [J.Karns] I've seen that book recommended for Linux programming on a LUG list I subscribe to. Additionally, this one:
The Design of the Unix Operating System, Pr. Hall, ISBN-0-13-201799-7 Moris J. Bach

(?) Thanks for the confirmation. I've got the Bach book and read it years ago. It is my reference for Unix internals. I will read the Stevens book just for the sport of it since it applies to my FreeBSD system. I am happy that it also applies to Linux.

(!) [Faber] Excellent book, IMO. I was re-reading it Friday night (yes, I need a life ;-) and still learning new things.

(?) I claim to have a life -- my peers don't agree with me when I start to talk about technical stuff. I'm almost finished with chapter 9 -- the stuff that talks about session leaders and stuff. Soon I read about signals -- almost like writing interrupt handlers only a little easier.

(!) [Faber] I don't do the kind of programming that you do, but I think the combination of the Stevens book and the kernel documentation (usr/src/linux/Documentation assuming you've installed the kernel sources) should do you well

(?) It will be not quite like an embedded project. That's what makes it fun because it will be more like standard Unix programming (which I have not yet done). I'll have to deal with such issues as do I run various servers as daemons? What if I want daemon-to-daemon communication -- do I use named pipes?

As I learn and discover, I will pass this type of information as 2 cent tips.

Thanks for that info, Fabor. I will keep that Linux Documentation stuff in my mind. I know that I ramble whenever I talk about this project that I am working on. Here's why, though.

When I was doing DSP (digital signal processor) programming, I would ask myself questions like "I wish that I could use DMA for those A/D samples." Then, I would turn around and discover that the feature existed.

Linux is the same way. I'm architecting this system as I were designing hardware to do the job. You want I/O? Use the messaging IPC. That allows programming language independence with respect to server implementation. Linux (and Unix) has all of these cool things that provide for a concurrent implementation of the system.

And that stability. The things that people can do when they work together!!


(?) What ISPs Do We Use for Linux

From Chris Gianakopoulos

Answered By Dan Wilder, Heather Stern, Thomas Adams, Faber Fedor, John Karns, Ben Okopnik, Mike Orr

(?) Hello gang, I am going to lose my Internet service provider at the end of this year because they are going to disappear.

I am visiting various web pages for ISPs out there, but, I am clueless about how to determine their (the ISPs) interoperability with Linux.

For example, I talked to the support staff at www.excelonline.com, and they said that their ISP service should work with Linux.

I'm not sure what the failure mechanisms are, and I will probably do lots more surfing of the web so that I can find a suitable replacement for my current ISP (provided by www.gateway.net).

About Linux Friendly ISPs... What does friendly mean? Does it mean that standard protocols are used?

(!) [Dan] The short answer is, "almost any ISP works with Linux, but don't count on technical support from most of them."
With most ISPs, you'll have to know how to set up your PPP, dhcp, whatever, yourself. Increasingly, people are going to DSL and cable, and you need to watch out for the ones who want you to put the router or modem inside your box. Some of these are unsupported in Linux. Better to go with a provider who furnishes an external router or modem.
(!) [Mike] An external modem will be more expensive ($200), but is worth it because it's "standard". My Cisco 678 connects to an ordinary Ethernet card, and is configured via telnet or a null-modem cable (minicom/kermit). (Actually, I could never get the telnet mode to work because I couldn't figure out the device's IP address on its configuration network. So I went the minicom way.) The modem is switchable between bridging and routing. The telco said I have to use bridging mode, so I'm directly on the ISP's network. The modem converts from Ethernet to DSL, then to ATM, then back to Ethernet at my ISP. For those that use the telco's own ISP, I hear they use routing mode over PPP.
The telcos/cablecos frequently have promotions where you get a free or discounted modem. And my ISP (oz.net/theriver.com, covering Washington and Colorado) has deals for ex-Covad customers now that Covad is bankrupt: free setup and installation for their portion of the fees and free first and last month. I expect other ISPs have similar deals.
(!) [Ben] By now, it's "you name it, and I've used it." I have not yet run into an ISP to which I couldn't connect (AOL is neither an ISP _nor_ anything that I want to connect to; I'd hate to wash my modem out with soap...) I've gone through, oh, at least a dozen ISPs - in the Bahamas, all over the Caribbean, in Bermuda, and a number of different ones in the States. Come to think of it, better make that around two dozen. :) I've used Ethernet, PCMCIA/serial/ USB modems, both wired and radio, and I'm about to try it via a cell phone. These days, I'm about to drop AT&T, their support policies and quality of service started from egregiously bad and took a sharp downward turn. And the rates. Blechhh.
Anyway - trust me: if it's at all possible, Linux has a way to do it.
(!) [Faber] Basically, yes. TCP/IP is TCP/IP and even Microsoft Exchange supports SMTP and POP. :-)
(!) [Heather] [For connectivity itself] most dialup places that speak MSwin-only use PAP.
(!) [John] Almost all services should work with Linux. Some might be a little more difficult to deal with than others, but most ISP's today use chap / pap and set things up to be compatible with the default MSW client internet connection cfg. I have found wvdial to work in almost all cases. Here in Bogota, virtually all ISP's are using w2k or other MSW platform servers, with no login scripts, which seem to be a thing of the past - which means less fuss for you. I have tried at least three different ones over the past 3 yrs and all have worked. Although sometimes (not too often) I have to try dialing more than once to get a connection due to PAP authentication gotcha's; but I tend to think that it's more an issue of telecommunications complications than anything else.
(!) [Mike] PAP and CHAP authentication are conceptually similar to an ssh login without a password prompt. It does send a login and password, but this is part of the built-in handshaking process rather than something you have to script. To troubleshoot, set PPP to debugging mode and watch the handshake strings and error messages. I haven't used pppd for years, but the most frequent errors I used to get were the one about the line not being 8-bit clean (you have to escape more special characters), or the mysterious "serial line loops back" or whatever, meaning it tries to contact the remote host but reaches itself; I think that means some client/server switch is wrong.
As they say, Microsoft loves industry standards so much that it never saw a protocol it didn't embrace and extend. NT4 had PAP and CHAP, but it was "Microsoft PAP and CHAP". pppd users had to install a patch, which eventually made its way into the standard package. Each version of NT/Win2000/WinXP may introduce similar subtleties.

(?) That's interesting (but not the least bit surprising) - I wasn't aware of that.

Cool -- I partly understand things. I noticed that my new ISP uses PAP. My (soon to be) previous ISP uses CHAP.

(!) [Faber] As Dan pointed out, just about any ISP will suffice, just don't expect any technical support. If you do require technical support, be preparedto switch over to Windows for the duration of the phone call.

(?) That's cool. I can live without the support -- It's more fun figuring things out myself (and with your help -- of course).

(!) [Heather] I have found that either wvdial or xisp or (there's a k toy, is it kisp? kdial? oh well, it was on freshmeat somewhere) work slightly differently, so if one doesn't work for you try the others before even starting to stress out. Jim does dialup. I haven't had to in years, though I can trouble shoot a raw PPP connection if I really have to.
Between freshmeat and the debian packages listing there are so many front-ends trying to make it easy to do dialup, it's hard to just pick one to use ;P

(?) That's true. Sometimes, I feel more comfortable doing it the "hard" way, just so I know how to set up the various ppp scripts. For my FreeBSD machine, I have two alternatives. I can use the pppd (our daemon), or I can use a program called ppp (a user space process). The latter is pretty cool, because, by turning on ip forwarding (with the sysctl command), and passing "-nat" to the ppp program, I get ip masquerading.

(!) [John] An important part of the issue might be to tell them that you're running Linux, and ask if they would have a problem providing answers to you regarding such a platform. If they turn up their nose at you, look elsewhere. I would maybe ask them what platform they are using for their operation, and look for one which is using a *nix / non-MSW platform.
There should be a number of ISP's that (still) fit this category. Another reason I would tend to avoid the MSW people would be that I would assume the *nix people might be a little more savvy technically speaking, as setting up a w2k / or NT box may done with a few mouse clicks - ok maybe several.

(?) Or does it mean that a bunch of advertising stuff does not clog your display window when using, for example, Netscape?

For example, a friend told me that when you use America Online, you need their special browser to interact with them. I thought that all browsers used http over TCP for the communications mechanism.

(!) [Faber] AOL is a proprietary network, with proprietary protocols. IMNSHO, AOL is not an ISP (in terms of a center that whose primary purpose is to let you gain access to the Internet) but a private networks which, coincidentally, you can access the Internet through.

(?) Now I see why this is so. ISPs I sort of understand. AOL, I did not understand (since I do not see their protocols in the textbooks that I read).

As far as email is concerned, I thought that POP and SMTP would be supported by each and every ISP (possibly a misconception on my part).

(!) [Mike] Every regular ISP supports POP. Some may try to steer you toward IMAP instead of POP because it's more "advanced". Of course, if you don't need IMAP's features (which allow complex operations on messages stored on the server, rather than downloading them to your PC and reading them there), POP works just fine.
(!) [Faber] As longas it's not a proprietary network like AOL or Delphi (is that one still around? What about Bix?), then you should be okay. But check with the ISP JIC.

(?) Very cool! I just tried an experiment using a friend's ISP account with the provider that I was interested in (with the friend's permission of course, and we were not simultaneously using the service), and it works! It was just a connectivity experiment -- not one to rob somebody's bandwidth.

So, my goals were to discover if ISPs are somewhat generic in their behaviors (it seemed logical that they should be). Thanks to your responses, and my experiment, I am now confident to proceed.

If a few of you could respond to the question "Which dialup ISP do you use with your Linux system", that would be cool. I'll go ahead and read the HOWTOs and figure out all of that chap-secrets stuff and make it work for my SuSE Linux distribution.

I guess that I am sort of lost because I am not getting the information that I want from the various ISP sites (due to my ignorance of course).

(!) [Dan] You didn't mention where you were.

... Not that this kept most of the Gang from jumping in, nor that the results might not also be useful to you, dear readers ...

(?) How silly of me, Dan. I forgot to mention that I am in the Chicago, IL area. Thanks for the ultra quick reply. I just tried an experiment with www.excelonline.com using my sister-in-law's login using my FreeBSD machine as a router. Therefore this particular ISP works with FreeBSD's ppp user space program. Linux should be free sailing -- I expect.

I gotta log off because the use of her ISP account (with her permission, of course -- she's sitting next to me) was only for experimental purposes.

(!) [John] With a *nix acc't you might want to look for an ISP which offers shell accounts. It's nice to be able to log in and read mail from their server if need be, or place a .forward file to have your mail temporarily forwarded somewhere else if you plan to travel to where there will be a local email account available.
And, there might be more reliability with an ISP using a *nix-based box. :-0
(!) [Mike] Good luck. Most ISPs consider shell accounts a security risk, generator of most of their tech-support calls ("Can you install/upgrade this mailreader/newsreader/ compiler/library?"), and not a marketing priority (because most of their customers wouldn't know what to do with a shell account if it bit them).
(!) [John] No doubt the shell acc'ts are rarer today than a few years ago. I admit that I haven't shopped for an ISP shell acc't for about 3 years; but at that time I did come across a few. Also, my Colorado ISP acc't which I've had since about 1995 is still a shell acc't. They use a kerberos'd DEC ultrix.
(!) [Dan] In the Seattle area, where our offices are located, we have a number of Linux-supportive ISPs, such as blarg.net, eskimo.com, serv.net, zipcon.net, oz.net, speakeasy.net, and others to whom I no doubt do an unjustice by not listing here. Some of these providers have points of presence in other cities.
(!) [Heather] My provider, Idiom.com, offers dialup. It's S.F regional and spreading, but I don't think it's nationwide quite yet. The owner is a big BSD fan so it's all free software under the hood, and an all-digital internal backbone. It may be more expensive than others, but we like getting our DSL from someone we can trust - not like those PacBell bozos...
For Jim and I, Idiom's dialup is mainly a backup for if we are out of town, but it's still handy.
(!) [Thomas] Hello. That is a shame that Gateway are cutting their ties with providing Intenet Access. I know of a few ISP's in the UK that are Linux "friendly":
www.uklinux.net
www.f9.net.uk
www.vigin.net
All offer PPP support allowing you to dial in.

(?) I did find a good ISP. At least the tech support staff answered their phone during a Saturday morning and afternoon. When I asked them if it took 25 minutes to service my phone call because of their heavy service load, they told me that there is only a few people around their on weekends. I suspected something like that. I almost gave up waiting, but, I decided to give them a fair shake (on the belief that they were real busy). It was worth the wait! When I asked them if they knew if their system would play well with Linux, they told me that they would help me if I had any problems. They the fellow said "We're just a bunch of computer geeks hanging around here" (or something like that). I saw their coolness (I'm somewhat of a geek too), and decided to give their site a try. They have a good staff at www.excel.com.

As things went, I had no problems setting things up on my FreeBSD machine (using user-space ppp) and no problems using Linux (using wvdial).

I'm rereading the HOWTO that talks about ip masquerading for Linux, because I do tend to give my FreeBSD machine and Linux machines equal treatment. It's making sense now...

Thanks much to all of you that answered! You all, once again, increased my confidence in this stuff. This is just like engineering -- lots of successes and lots of time me being humbled. There's always something to learn in this protocol world (and Linux world). That's what makes it so much fun.

Chris Gianakopoulos


(?) How to let the world find your Linux Server when using DHCP

From Jason Bailey

Answered By


Abstract

Many of us have broadband connecting our Linux machines to the Internet and would like to play around with our own webservers, but for a variety of reasons are unable to get a static address. This article should help you with publishing your Linux server's current IP address to an ISP's web server.


Introduction

I've wanted to have my own web server for many years. Partly because I'm a geek who has a need to do things just because I can. But more importantly, I've wanted to do it because many ISPs don't let you play with cool stuff like databases, perl, php, python, etc.
So what's the big deal? You say. Set up a Linux box and you are good to go. Well, it is that easy if you don 't care about sharing this website with anybody else. My ISP won't give me a static IP for my cable modem. So I thought, what if I could create a webpage on my ISP's web server which would point to my web server? The game was afoot! I began searching google.com and pestering the members of my LUG (Linux Users Group) for ideas.
One of the most helpful articles I found was written for Linux Gazette several years ago by Henry H Lu. I have followed a lot of his basic ideas, though I have reduced the number of files used and I've standardized on shell script as opposed to using both shell script and perl. Henry does have a nice example of how to make the FTP portion work with Geocities if you happen to be using them.


Automating FTP

The file transfer protocol client interaction can be a bit difficult to script if you are having to wait for prompts for username and password. One way around these prompts is to use the .netrc file. The layout for the file would be as follows:
machine www.MyISP.com login JoeUser password Top$ecret
Please note that you must change this file to read/write owner only when you create it. For more information about the .netrc file and its uses do a man netrc at you command prompt.


HTML File Template

I found that the easiest way to do this was create an HTML file which has a placeholder everywhere I want the IP address to go. I chose "~~~IP~~~" to be my placeholder since it stands out and I'd never have it appear anywhere else in my document. The following is an example of what you might use.

See attached up.html_source.txt


The Shell Script

I'll first show the script and then explain what each part does.

See attached dhcp-myip.sh.txt

First, we find the IP address using ifconfig on our WAN device (depending on your setup it may be eth0, ppp0, etc) and parse out all information we do not want. If you are not sure if you are using eth0, eth1, ppp0, ppp1, etc you can type ifconfig to see which devices you are currently running and look for the
one with a valid Internet IP address.
We save the IP address in the variable MyIP and in an ASCII file. Then we com pare a file that contains the current IP address and one that contains the IP address which we had the last
time the script ran. If these two
addresses are the same we are done. If they are different, we use take our up .html_source file and replace ~~~IP~~~ with our current IP and store the results in up.html. Next we FTP th e file to our ISP. Finally, we copy our current IP to "MyIP.then" for future referen ce.
Make sure you do a chmod +x to the script after you save it.


Repeating the Process

After you have tested out the script, you'll probably want to have it run eve ry five to fifteen minutes. You can easily to this by adding a cron job. It is important that you run the cron job as the user w ho has the files in his home directory and has the FTP server information in his .netrc file.


Conclusion

If you want to make your web server, which is on a dynamic IP address, easily
found by your friends and other. This script can
make it as easy for them to find your home server as going to http://www.MyIS P.com/~JoeUser/ip.html. The scripts are easy to reconfigure to suite your needs. My next step is to write a PHP script tha t will ping my IP address and if it gets a response it would send you to the server. If no response was received, it wou ld give a page that explains that the site it down. I hope you find this as useful and fun as I did.
Jason Bailey

When I'm not at work doing system admin stuff, at school pursuing my Computer Science degree, at a Susitna Linux Users Group meeting or off doing freelance computer work, you can find me hanging out in beautiful Palmer, Alaska with my wife and kids.

(?) trouble w/ dual boot

From Jeferson

Answered By Mike Orr, Heather Stern, John Karns

(?) <html><head><meta http-equiv='content-type' content='text/html;'>

(!) [Heather] Aaaaargh :) allow me to quote my favorite wimpy, but totally virus proof mailer --
[text/html is unsupported, treating like TEXT/PLAIN]
(somewhat after the fact, I note that there can be good reasons to do this - foreign character sets maybe - but leave plaintext plain, okay?)

(?) Hey guys, how r ya doing huh ?

I'm having a little problem here with my OS, I've installed Conectiva Linux in the Master HD and I had the MS windows installed ins the Maste Slave hd, what can I do to have a graphical interface or even an easier way to boot in the system, without having to go to the system setup and change the boot order ...

Can ya help me ???

(!) [Mike] Have you looked at the HOWTOs at www.linuxdoc.org? http://www.linuxdoc.org/HOWTO/HOWTO-INDEX/howtos.html Search for "Windows" and "Win" in the text. There are several HOWTOs about making Linux coexist with Windows.
Also poke around www.linuxnewbie.org for other information you might find useful.

(?) I've already looked at the HOW-TOs and my problem is a bit different, there is any way I can manage the boot, like... now I want to boot with Win32, I just reboot the pc and choose MSWIN, later I'll be in a mood to boot with Linux, then I reboot the system and choose LINUX, I've already tryied with "system commander", the Grub... wait a second, isn't grub a graphical interface for the LILO ? how can I change the configurations of the lilo, where is it's configuration file?

(!) [Heather] /etc/lilo.conf is a text file that /sbin/lilo (a progam) uses to compose LILO (the boot loader). It's usually quite well documented in /usr/share/doc somewhere, in a directory named either lilo, or lilo with a version number. And in 'man lilo' plus those HOWTOs that Mike mentioned.
grub is not a GUI for LILO particularly; it's a boot loader in its own right. But you can use it to point at LILO as a second stage if you want.
GAG, the initials are for the spanish words of "Graphical Boot Manager", is an entirely GUI bootloader, and it is its own configurator - that sounds a bit more like what you are really asking for. The link's quite slow for me but might be a bit closer to your ISP there in Brazil:
http://www.rastersoft.com/gageng.htm
Gujin is another alternative bootloader, it's supposed to be smart enough to look for bootable drives or kernels on its own, so it doesn't need setup:
http://gujin.sourceforge.net
But if I misinterpreted what you want, there are GUI tools which run under X to help you set up /etc/lilo.conf - among them Glilo (GTK), Klilo, lilo-config, or BootRip.
(!) [John] Also, later versions of lilo have a gui-like interface which offer a menu with a 'point & shoot' menu-bar. BTW, even the older lilo versions offer a "menu" of sorts, if you press the '?' key at the boot prompt, which will display a list of available choices; although you still have type the selection rather than "point & shoot". Even this can be minimized by using a short label in your lilo.conf:

See attached jkarns.lilo.txt

If your machine is fast enough and has ample memory, you might also consider installing VMWare, and avoid having to reboot. Although if you're a gamer, it might not offer what you want. Anyway, they are offering an "express" version for $50, which isn't so expensive. I've been very happy with the software, but it's running on a 700 Mhz machine with 128 MB of RAM. Even w2k runs fast enough to be satisfactory. I also purchased a copy to run on a 500 Mhz / SCSI machine which is a bit slower, but still tolerable. A 380 Mhz / IDE / 64 MB machine is also usable, but a bit too slow to be pleasureable.
There are other products available both commercial (e.g., Win4Lin) and GPL (Wine). Re: wine, it is indeed a formidable task to emulate an entire API on a foreign OS. They deserve lots of credit for getting as far as they have, but it's still alpha. I haven't looked at Win4Lin so can't comment, except to say that I believe that VMWare is the most mature product in this venue. BTW, they also offer a version for w2k / NT to host Linux, but since I think that Linux is the more stable OS, it seems a better idea to use Linux as the host =:<)
(!) [Heather] Well if he is a gamer, I really think he ought to look at Transgaming (http://www.transgaming.com) and see if their WINE + ActiveX solution works for his games. I saw a demo at LWE and it ran Diablo for MSwin directly; I was impressed.
Lilo also supports a value called "alias" and if you make it a single character then you can even get one-tap loading. Here's about the simplest example that works -- assuming you have the world's plainest configuration, basically, C: at the start, "all one big slash" for the second partition with a linux kernel named "vmlinuz" at its root, your swap partition invisible at the end, and no framebuffers or other hardware oddities requiring an "append=" line. /vmlinuz could be a symlink to wherever you really keep your kernels, if you prefer.
boot=/dev/hda2
single-key
image = /vmlinuz
  label = linux
  alias = 1
other = /dev/hda1
  label = dos
  alias = 2

(?) PS: Sorry about the HTML

(!) [Heather] That's okay, now you know :)

(?)

Thankx
Jeferson

(!) [Heather] You're welcome

(?) HOWTO find a good laptop

From William Thornton

Answered By Heather Stern, Faber Fedor, John Karns, Mike Orr

(?) Just wondering if you can point me to any good web resources on what laptop hardware is currently supported under linux. What I've been able to find are how-to's (as in how to install linux on a laptop. And these seem to be out of date. You can't even buy the models listed anymore.) Any help would be greatly appreciated. Thanks.

(!) [John] One of the originals - and most extensive - was Kenneth Harker's "Linux on Laptops".
It was at utexas.edu, but that URL has since changed, and unfortunately I don't have the updated one.
(!) [Faber]
For those of you watching at home, the link is, of course...
(!) [Heather] ... Kenneth Harker's site full of links to personal testimony and other resources: http://www.linux-laptop.net
Or Werner Hauser's Mobilix:
http://www.mobilix.org
Alternatively you could cheat, and buy a laptop from a vendor that sells laptops pre-loaded with Linux...
Distros have gotten better about being able to be installed on a laptop; the rise of laptops with accessible CD bays has helped a lot too.
The important thing to know is that you should consider your parts of hardware individually when looking at buying a laptop. Model names and numbers themselves are immaterial, except that those may make it easier to find fellow users of the same hardware. Yes, the same real manufacturers sell through many vendors, with the exception of a few giants like Sony and IBM that build their own stuff.
USB
pretty much no problem. The command 'lspci' can tell you if you have UHCI or OHCI, then you can load up the right one and rock on.
Infrared
Find out what chipset it has (this is harder than it looks, just "fast" doesn't cut it). Linux supports several but to get Fast IR you need to know which kind, and it needs to be one of the small handful we handle. Mobilix has good info.
Mouse
luckily most mice are just PS/2; there are a few synaptics style touchpads out there, that have a PS/2 compatible mode anyway. Those "jogdial" things Sony has need a special program, but we have one.
(!) [John] ... and now those of the USB variety are available. I have been using one for the past few months, since I purchased a Dell Inspiron. This allows using an external keyboard which helps to make the laptop a better replacement for a desktop. That way I can use both an external mouse and keyboard, and still have the serial port free for an external modem should I choose to use one.
(!) [Heather] Video card
If you're planning to slash the bleeding edge, you really have to be sure on this one. It's one of the parts you cannot easily replace! Note that some manufacturers throw their own cheap X servers together - check into them further and see if they are going the XFCOM route (which eventually leads to the source being merged with XFree, when the card is yesterday's news) or staying proprietary. And whether they need a kernel module to support GL and/or acceleration. (hey, that'd be sweet. But I wouldn't bet on finding that.) If you're a gamer, check if the video has proper texturing support. Many don't.
Also, X 4.1 is getting there, but there still might be a few cards better supported under X 3.3.6.
Driver Status for XFree86[tm] 4.1.0
http://www.xfree86.org/4.1.0/Status.html
For libvga I always recommend trying the VESA setting before giving up. And setting the VesaSave value to a different number can help solve if it's coming out with a text mode that puts your cursor below the screen :)
(!) [John] I had a rough time with the Inspiron - the only way I could get X to work was by DL'ing the XF86Config file from the mfr's Internet site; and I have yet to get it to work for other resolutions than 1400 x 1050. Even though they offer several to cover various resolutions, they did a very poor job - some were just duplicates under different names.
Be careful of the ATI r128 chip series. There are around 10 different variations of that chip, designated as r128 SM, r128 RE, etc., and they are not compatible; so check the X docs to verify that the chip is supported - or better yet verify that the chip is indeed the same as one of the models mentioned on one of the Linux laptop sites, i.e. that it has not been changed by the mfr for the currently shipping models.
(!) [Heather] ATI is actually rather infamous in the community for generating new troubles with every minor BIOS and circuitboard revision. That problem is not at all limited to laptops :(
Your monitor
Sounds odd, but yes, this needs to be considered seperately.
Try to get X modelines from someone else who has the same screen. They don't need to be from the same distro, and in fact, you can steal modelines from an XF86Config that's meant for version 3 and use them on version 4 just fine. You cannot steal the whole file and use it though - the format has changed a bit. Put your modelines in the Monitor section, in either case.
Sound
You actually have a pretty good chance here. So far lspci has always been good for me at coughing up what chipset the sound is, and after that it's easy to look up. (This doesn't work on older models that have ISA sound, but you're talking about new machines here.) The important tidbit is, there are three different ways to get sound support working, and you only need one of them to work. In order of preference, it can be a normal kernel module, the ALSA project probably has drivers for you, or you can use OSS. SuSE makes sound setup easy. Your distro may vary.
http://www.alsa-project.org
Ethernet
Usually isn't much of a problem. lspci should tell you what it is, then just load the right module. In fact lspci is usually better than the box for telling what's in it; many manufacturers are licensing chipsets these days.
If you have a builtin modem...
Ouch. Most of these are winmodems, er, 'scuse me, "controllerless". In other words they are born missing one or two of the three core chips that make a real modem work. For anyone who's been under a rock for the last few years, that means that they are "easily upgradable" but also cheap and prone to breaking down under heavy CPU load.
I list the ones mentioned at linmodems.org here, because many of the projects have moved recently. The linmodems links still work too.
Don't be afraid to buy a PCMCIA card to replace these. Nobody will blame you. But do check the resources at linmodems before buying a card - some folks have been burned by PCMCIA softmodems, those pretty much don't work for us.
(!) [John] In my case, I had to DL the pcmcia pkg from the 'net and install it separately after installing SuSE 7.1 due to a quirk with the newer TI PCI4451 PC card Cardbus Controller chip that the machine uses. Trying to use the SuSE packaged version would hang the machine. This was explained in one of the pages about my machine referenced from the harker site.
Also, one can check the docs that are pkg'd with the pcmcia stand-alone pkg. There has in the past been a document included which lists the cards known to work, with the caveat that card mfr's sometimes change the chips inside the cards without changing the model designation - it's rare but not unheard of, so you can find yourself with a card that doesn't work, even though it's on the compatible list. I've had pretty good luck with Xircom in the past - a CEM33/10 and a CEM56/100 which both have a full modem implementation rather than a winmodem (the only people who 'win' are the mfr and Microsoft :-( ).
(!) [Heather]
(!) [John] These are perhaps the most ubiquitous of winmodems, and some say offer the best chance of working under Linux.
(!) [Heather]
(!) [John] Dell was shipping two versions which they were designating as mini-pci 3com ether combo cards. The one that was shipped in my machine is known under the name of Actiontel, and has an LTModem paired with an Intel eepro-100 ethernet chip - luckily for me both components are Linux compatible; probably because they were offering machines pre-installed with Linux. They have since changed their policy and are no longer offering pre-installed Linux, except on their servers. Consequently they are now shipping one of the modem chips mentioned above, which people don't seem to having much luck with, and many have bought a pcmcia card to use instead. However, there are two items of interest in this regard, IMO:
  1. many of the pcmcia cards seem to run quite warm, even hot - especially the ether / modem combos cards, which adds extra heat to your laptop, and also means more battery drain.
  2. many laptops are implementing the ether / modem combo cards for the mini-pci slot connector which is also being offered on many desktop style mobos. This connector very much resembles the one used for the type of memory module (so)dimms currently being used. Thus if desired it is possible to purchase one of these from an after market 3rd party and replace an incompatible card with one that is Linux compatible.
(!) [Heather] Did I miss anything?
Oh, probably. But if you have a feature listed that you're wondering about, try Google! Linux (http://www.google.com/linux - and do NOT put a slash on the end) and type in the buzzword or chipset. Chances are good you'll find something on it.
(!) [John] ... not too much!
Just one more thing. We need to make the hardware co's more Linux cognizant. Be sure to mention that you're buying the machine because you have reason to believe that it is Linux compatible, and if it wasn't you wouldn't be purchasing from them! Also mention any items that you know not to be compatible, such as the winmodem. Express your interest that they consider increasing their Linux support in the future.

(?) Wow! I thought I MIGHT get one answer to my question. Instead I get three very good answers. The info at linux-laptops.net seems to be much more up to date than what I'd been finding.

Thanks! I should be pretty well armed with info for my next trip to the computer store.

(!) [Mike] Thanks for the encouragement.


This page edited and maintained by the Editors of Linux Gazette Copyright © 2001
Published in issue 71 of Linux Gazette October 2001
HTML script maintained by of Starshine Technical Services, http://www.starshine.org/

More 2¢ Tips!


Send Linux Tips and Tricks to


LJ Tech Tips

September 2001

Private domains

If you give an example hostname in documentation or as part of your answer in an on-line forum, use one of the safe domains listed in RFC 2606. example.com, example.net and example.org are not assigned to anyone, so you can safely use them in examples without someone's actual server getting slammed if a reader takes you literally.


On-line dictionary

When someone says you're "meretricious", that's a compliment, right? Not necessarily. Save yourself a trip to the library with the easy-to-use dict utility by Rik Faith, available on the dict.org web site: http://www.dict.org/links.html

The Dictionary Server Protocol is RFC2229

Or use Merriam-Webster's dictionary:
http://www.m-w.com


Telnet via http

If you can only do HTTP from work and want to send resumés from your shell account, check out GNU httptunnel. It encapsulates any TCP connection in an HTTP connection, so it will work through an application-level proxy.

(PPP over ssh over httptunnel is left as an exercise for those readers who really want to give the corporate security pigs the finger.)

You can get more information from Nocrew.org:
http://www.nocrew.org/software/httptunnel.html

or from GNU.org:
http://www.gnu.org/directory/httptunnel.html


Changing the title bar on an xterm

"xterm" isn't a very helpful window bar title for an xterm. You can put extra information in the title bar, however, with escape sequences. For example, this repeats your shell prompt both in the title bar and the command line:

export PS1="\[\033]0;$PS1\007\]$PS1"

For more xterm title bar customization, see the Bash Prompt HOWTO by Giles Orr:
http://www.shelluser.net/~giles/bashprompt/howto/xterm-title-bar-manipulations.html


Running BIND as non-root

One of the main rules of security is "Don't run anything as root that you don't have to." To run BIND as a non-root user, first create a user and group "named", then add the -u (user) and -g (group) options to the init script for BIND.

On some distributions the init script is called "bind" and on others it's called "named".

For example, in Debian, change the "start-stop-daemon" line in /etc/init.d/bind to:

start-stop-daemon --start --quiet --exec /usr/sbin/named -- -g named -u named


HTML Tidy

Got old web pages that are so messy you just stick a couple of extra </table> tags on the end and hope for the best? Try HTML Tidy, the pretty-printer for HTML, available from the HTML Tidy web site: http://www.w3.org/People/Raggett/tidy or your favorite Linux packages site.

HTML Tidy fixes common HTML mistakes and puts everything in an easy-to-edit format. The author claims it does a good job of stripping excess markup from Microsoft Word documents saved as HTML, too.


Moving Internet services among servers

To keep the flexibility of moving services from one system to another without reconfiguring all the clients, it's a good idea to set up CNAME records in your DNS. Some good examples are "pop", "smtp", "news", "shell" and "webproxy"--that way you can move the outgoing mail server or the Squid server to its own host without having to reconfigure all the clients.

But with the increasing number of mobile users, don't make the mistake of, for example, setting client software to only use "smtp" and "pop" for their mail. Fully qualify the domain name, so that when they take their laptops to the leetconference.com network, they don't end up trying to send their mail through smtp.leetconference.com by mistake, and get it bounced back for attempted spamming. Configure client software for CNAMEs like smtp.internal.example.com.


(sendmail 2c TIP) * 2

Thu, 13 Sep 2001 18:50:56 -0700
Guy Milliron ()

2c TIP: Sendmail ignores everything after a plus symbol in a username field of an email address. Hence if while cruisin the Wild Wide Waste, you come across something that needs your email address, you and put in [email protected] When you get mail/UCE/Spam to that address, you'll know who sold it, or put it on a web page and a spider ran across it. Even works on webpages when you want to put a "Mail Me" link. At least you know a spider harvested your address.

Which leads into another 2c TIP. I use /etc/aliases file to control my mail. Like I could alias "fubar" to my normal email account "guy". If for some reason I get a lot of spam from that email address "fubar" - I would just delete the alias "fubar" from the file, and the "account" is gone, but my normal email address is intact for my friends to use.

I do this with my clients that I host for. I inform them of the benefits of aliasing, and then offer each account they have up to 3 aliases.

Smile
--
Guy Milliron


A 2 Cent About Converting Image Files

Sat, 8 Sep 2001 18:04:03 -0500
Chris Gianakopoulos ()

Hello Answer Gang, Sometime this week, I noticed that somebody was asking about how to automating the Gimp so that it could convert image file formats from one format into another from the shell command line.

I cannot remember who it was, because I lost the email, thus, I'll post this message and hope that the person will see my posting.

The ImageMagick tools will do the trick. They have a utility called "convert" that can do the necessary conversions from the command line.

I must give credit to the author of the article. Her name is Katja Socher, and the URL is http://www.linuxfocus.org/English/July2001/article211.shtml. Her article is entitled "Do magic with images on the shell". She shows all kinds of cool things that can be done with ImageMagick.

I just stumbled on the article, and by coincidence, I was also trying to find a tool to convert images from one format into another. Of ImageMagick can do much more than convert images.

Chris Gianakopoulos


While in hack mode...

Sat, 15 Sep 2001 15:28:55 +0000
Ben Okopnik ()

Back in LG#60, one of our readers ("Roy") posted a little Tcl/Tk script to TAG - in effect, this thing pops up a little 'sticky note' with a message, and goes away when it's clicked. I saved it, and put it to use occasionally - it's a rather useful toy. A few minutes ago, however, I happened to glance at the code, and noticed that there was a "dead" section in there, code that was supposed to execute but didn't. So, having fixed it and added a usage message, here's the 'New and Improved' version of the script I called "3m" for semi-obvious reasons:

see attached misc/tips/sm.tcl.txt

Contrary to the original author's statement, "funny characters" (shell metacharacters) can indeed be used in the message; simply enclose the entire message in single quotes.

# This displays the message and saves it with a timestamp
3m - Lunch with Liana, 1:00-2:00pm Sunday &

# Oh-oh - here come those funny characters!
3m 'Watch out for Larry, &Moe&, and %Curly%!!!' &

Tcl/Tk will simply display the quoted text enclosed in curly braces. Also, note the (unquoted) '&' at the end of the line - this puts the process in the background, and allows you to continue using your xterm... perhaps to launch more 'sticky notes'. :)


xshowrgb (xcolorsel replacement)

Mon, 17 Sep 2001 15:52:11 +1200 (NZST)
Ryurick M. Hristev ()

Hello,

For your 2c Tips page:

Attached is an perl script as a xcolorsel replacement (xcolorsel doesn't work on X11R6).

Require the perl-Tk package (RedHat users may find it on the Developer Module Archive disk).

see attached misc/tips/xshowrgb.perl-tk.txt

Cheers,
--
Ryurick M. Hristev

I usually use xcolors or gcolorsel, myself. With the caveats that xcolors creates a huge window and gcolorsel requires GNOME, they're enough for me to get a quick eyeball on the named color I want to use. -- Heather


re: kernel compilation error in issue 70

Tue, 11 Sep 2001 00:12:55 -0400
Kenneth Veith ()

Hi,

I ran into similar problems. The following, from RedHat's site, fixed the problem for me.

7.1 Compiling a kernel from source in Red Hat Linux 7

For various reasons, gcc is no longer able to compile the kernel from source because it uses the 2.96 version of the GNU C Compiler. However, it is still easy to compile your kernel, as version 2.91.66 of the egcs C compiler has been included with the distribution. Please note that the details involved with compiling a kernel are not covered here. For more information please read the Linux Kernel HOWTO at http://www.redhat.com/mirrors/LDP/HOWTO/Kernel-HOWTO.html. This document is assuming you have a basic grasp of what is necessary to compile a kernel and simply cannot get the @$&%@$@*% thing to compile in Red Hat Linux 7. This information only applies to pristine source, downloaded from a site such as kernel.org, as the changes necessary to compile have already been made to the source from the kernel-source-2.2.16-22.i386.rpm package.

After downloading and extracting the source in /usr/src, cd to/usr/src/linux and open the Makefile in your favorite editor. You will need to look for a line similar to this:

CC      =$(CROSS_COMPILE)gcc -D__KERNEL__ -I$(HPATH)

This line specifies which C compiler to use to build the kernel. It should be changed to:

CC      =$(CROSS_COMPILE)kgcc -D__KERNEL__ -I$(HPATH)

for Red Hat Linux 7. The kgcc compiler is egcs 2.91.66. From here you can proceed with the typical compiling steps.

The url for this is
http://www.redhat.com/support/docs/gotchas/7.0/gotchas-7-7.html#ss7.1

Hope this helps.
Kenneth Veith


Tarpit

Thu, 20 Sep 2001 11:03:21 -0700
Mike Orr ()

Here's a tar pit program that sits on unused IP addresses and plays with Internet worms.

http://www.threenorth.com/LaBrea

Courtesy Slashdot. -- Mike


Monitoring log files in real time

Thu, 20 Sep 2001 13:06:48 -0700
Mike Orr ()

When you're debugging a program that writes error messages to a log file, run "tail -f LOGFILENAME" in another window. You'll see the error messages immediately when they occur.

If it's hard to distinguish the lines referring to the latest error, press Enter a few times in that window. That won't affect the file, but it will put a few blank lines on the screen. Then it will be easy to see where the next error message starts.

-- Mike


HSP Micromodem

Mon, 10 Sep 2001 21:58:22 -0500 (COT)
John Karns ()

JJ asked:

Pie ChartsHi all, I'm desperately looking for a driver for my HSP56 Micromodem, a device integrated on my Mainboard. Could you suggest some site to download it?

Try searching for "linmodem" with your favorite search engine - I usually favor google for Linux related searches. There is a site dedicated to information regarding setting up modems under Linux, and is called something like www.linmodem.org. I can't remember whether it's .org or .net, or something else.

-- John Karns

It's plural, and .org ...
if anything calls itself an "HSP" "HSF" or "HCF" modem, this is the place to see if linux hates it or can deal with it. -- Heather
http://www.linmodems.org/


Query about Makefile

Tue, 18 Sep 2001 22:10:39 -0500
Chris Gianakopoulos ()

Amol wrote:

Hello everybody ,

I am new to this Linux field . I just want to know all information about Makefile concept used for compling and configuring Linux kernel . Where can I get good resource about Makefile ?

amol

Hi Amol, I read a book entitled "Mastering Make, A Guide to Building Programs on DOS, OS/2, and Unix Systems" by Tondo, Nathanson, and Young. The ISBN is ISBN 0-13-121906-5. I suspect that the O Reilly book about make is also good.

Hope that helps,
Chris Gianakopoulos


Re: linux signwriting programs

Tue, 4 Sep 2001 10:11:42 -0700
Mike Orr ()

Steve Gosden wrote:

PLEASE SEND ME TO A SITE WHERE I CAN DOWNLOAD A SIGNWRITING PROGRAM THAT USES LINUX.
REGARDS STEVE

The 'banner' program prints large ASCII banners. On Debian it's /usr/games/banner, part of the standard 'bsdmainutils' package.

If that program isn't suitable, tell us more about what kinds of signs you're trying to make.

Do any Answer Gang members have recommendations for making signs with colors or signs with graphics?

You could try one of these:

-- Heather

Long ago on the VAX/VMS mainframes we used to make ASCII-art signs that showed Snoopy holding a sign with your text on it. Since the printer used that tractor-fed paper, it was easy to make a wide sign. The program might have been called 'banner'.

We had them in my old PDP-11 days, certainly. -- Heather


This page edited and maintained by the Editors of Linux Gazette Copyright © 2001
Published in issue 71 of Linux Gazette October 2001
HTML script maintained by of Starshine Technical Services, http://www.starshine.org/

"Linux Gazette...making Linux just a little more fun!"


A Need for Documentation

By


Contents

1 Introduction

Giving everything a GUI has become a popular trend in the Linux community. This implies that more and more program authors tend to use a GUI-based configuration dialog.

However, you lose an important thing when GUIs are used for everything: documentation. People who can point-and-click are often the one who think: ```Why should I read the programs documentation? I simply point-and-click--and it works.''

But it would be better to encourage people to read documentation. In fact, the better the documentation, the simpler it is to use a program. Take the Apache web server for example, it comes with heavy documentation. As a result, anybody who can understand a little English is able to use Apache and configure it--without using a point-and-click interface.

This article tries to encourage programmers to document their projects, as well as to provide ideas and tips on doing so.

2 Why should I write documentation?

Lots of reasons! More documentation means easier usage. More documentation means better add-on modules. More documentation means happier users. As soon as a user gets stuck trying to get a program feature to work, he or she starts to read that program's documentation. Imagine, therefore, creating well-structured and well-written documentation that will make it easy for the user to get that feature to work.

3 What aspects of my project/program should I document?

In general the following aspects of a program or project should be documented:

  1. Basic usage is mostly covered in a man page.
  2. More advanced usage can be achieved by listing ALL configuration options in the documentation and giving examples on how to use them (take the very good Apache documentation for example).
  3. Source code, of course, because somebody may want to add features to the program.
  4. Examples of usage to supply a working basic configuration file and document it heavily.
  5. Installation of the program, because not all programs work with ./configure && make && make install.
  6. User interface, especially if it is not a common point-and-click one.
This list can be extended further. But in general a well-documented program will cover at least these, and it will do so in a readable fashion.

4 How do I write documentation?

Use your favourite text editor, as the formats I propose here can all be written using a text editor.

Style is worth mentioning as well. Write your documentation in an easy-to-read style. Do not try to use poetry.

The preferred language for documentation is plain English, as almost anyone who uses a computer is able to understand it. You can always add documentation in your native language as well. But keep in mind that not everyone speaks German or Russian. At least include English documentation for the most basic parts of your project. Someone who cannot understand the simplest parts of the documentation will not read it, and in many cases he will not use that program.

The rest is up to you. Always keep in mind that writing the documentation is the ugliest part of developing.

5 What formats should I use for my documentation?

5.1 File formats suitable for documentation

Use a standard one, nobody likes proprietary file formats. This effectively kills MS Word, StarOffice or anything like that for documentational purposes.

The most simple format is plain text. It can be read everywhere, and everyone can use his or her favourite pager or editor.

If you want your documentation to be printable, LATEX is a good choice. It is relatively easy to use, at least for writing a documentation file. Advantages of using LATEX are the system-independent output format and a stylish formatted document. You can even export it to HTML.

The most preferred choice nowadays is HTML. It is hypertext, there are readers for all platforms available, and it can be distributed on the project's homepage for on-line reading.

You can also use an SGML- or XML-based format such as DocBook or LinuxDoc/SGML. These formats provide the most flexibility for converting to many other output formats (including formats which haven't been invented yet), or parsing as structured text (for automated text-processing tools), but require a learning curve similar to LATEX.

5.2 Source code documentation

Source code can simply be documented by heavy use of comments and suitable variable names. API descriptions in an external file is important, especially if you're writing a library or something else that can be extended.

6 Documentation formatting with HTML

Always use the most common subset of HTML. Do not use frames or Javascript in documentation. Simply use <H1></H1> to <H6></H6> for sections and <P></P> for paragraphs. Read your favourite HTML-Howto for more detail.

7 Use LyX

This my personal tip for writing program documentation. It features what-you-see-is-what-you-mean input and result formatting in LATEX, as well as export to ASCII and HTML. Think of it as some sort of GUI frontend for LATEX. Always keep in mind that LyX is not a WYSIWYG text processor.

LyX comes with most Linux distributions, with its own documentation file. Give it a try--it's easy to use and the results are stunning.

The export features of LyX make it well-suited for our purpose. You can create a .dvi file of your documentation that can be printed on almost all Linux boxes configured for printing. So even the distribution of a printable manual is easy.

8 What about PDF?

PDF is an extended version of Postscript. Its main disadvantage for documentation is it requires a graphic display or a printer to be viewed properly.

PDF is also less reliable on Linux. HTML files and man pages "just work". LATEX files work if you install the software correctly. But there are incompatibilities between the various PDF-authoring tools and viewers, and you may end up distributing a document that somebody can't open or that has some of the text showing up blank in various viewers.

PDF files are also huge, especially if you include pictures and tables. Displaying PDF files is slow compared to HTML, DVI or plain text. You may use it--but I do not recommend PDF for project documentation.

9 Conclusion

Writing documentation can be fun if you use the right tools. Always remember that the documentation should be written so that anyone can read it.

Now, go do it--good documentation is worth the effort.

Matthias Arndt

I'm a Linux enthusiast from northern Germany. I like plain old fifties rock'n'roll music, writing stories and publishing in the Linux Gazette, of course. Currently I'm studying computer science in conjunction with economics.


Copyright © 2001, Matthias Arndt.
Copying license http://www.linuxgazette.com/copying.html
Published in Issue 71 of Linux Gazette, October 2001

"Linux Gazette...making Linux just a little more fun!"


Code Optimization Using the GNU C Compiler

By


This article describes some of the code optimization techniques used by the GNU C Compiler, in order to give the reader a feel of what code optimization is and how it can increase the efficiency of the generated object code.

Contents

  1. Introduction
  2. Assembly Language Code for a C Program
  3. Constant Folding
  4. Common Subexpression Elimination
  5. Dead Code Elimination
  6. Strength Reduction using Induction Variable
  7. Conclusion
  8. Acknowledgments
  9. References

1. Introduction

As we all know, a compiler is a program that reads the source program in a high-level language and translates it into (typically) machine language. This is a complicated process involving a number of stages. If the compiler is an optimizing compiler, one of these stages "optimizes" the machine language code so that it either takes less time to run or occupies less memory or sometimes both. Of course, whatever optimizations the compiler does, it must not affect the logic of the program i.e. the optimization must preserve the meaning of the program. One might wonder what type of optimizations the compiler uses to produce efficient machine code? Since in no case the meaning of the program being compiled should be changed, the compiler must inspect the program very thoroughly and find out the suitable optimizations that can be applied. As we may wonder, such a thorough analysis of the program and then finding and applying suitable optimizations is a complex and time consuming process, the details of which are beyond the scope of this article.

What I am going to describe in this article are a few type of code optimizations that the GNU C Compiler uses so that we can understand how the code is optimized and appreciate the complexity of the optimization process. The GNU C Compiler is a sophisticated optimizing C compiler that uses a large array of optimization techniques to produce efficient code. It may not be possible to describe all of them, so I have chosen some that are interesting and also easy to understand. A complete list of the optimization techniques that are used by the GNU C compiler is available at http://www.redhat.com/products/support/gnupro/gnupro_gcc.html. Instead of simply describing what a particular optimization technique does, I will describe them using the assembly language code that is generated by the GNU C Compiler. This method will also enable the readers to further explore code optimization carried out by the compiler and also the advanced optimization techniques, in case they are interested.

2. Assembly Language Code for a C Program

The GNU C Compiler (called GCC henceforth) reads a C program source file and translates it into an object program that contains the machine code for the program in binary form. However, it can also produce assembly language source code for the program instead of the object code, so that we can read it and understand how the assembly language program looks. We will be generating such assembly language files to see the optimizations being used by the compiler, so it would be beneficial if we see how the assembly language code for a simple C program looks like. However, also note that we need not understand each assembly language statement in the generated code, so some statements that are not crucial towards understanding the code optimization will not be explained for simplicity. To generate the assembly language code, create a file test1.c as shown below and give the following command:

$ gcc -c -S test1.c

This will generate a file test1.s, which has the assembly language listing of the generated code for the C program. The file test1.c along with the assembly language code is shown below.


 1 : /* test1.c */
 2 : /* This first file simply demonstrates how the assembly program that the
 3 :    compiler produces looks like and some peculiarities of the GNU 
 4 :    assembler that follows some different conventions from MASM/TASM.
 5 :  */
 6 : #include <stdio.h>
 7 : 
 8 : int main()
 9 : {
10 :     printf("Hello, World\n");
11 :     return 0;
12 : }
13 : 
14 : /* end test1.c */
15 : /* ----------------------------------------------------------------- */
16 : /* generated assembly language file */
17 :     .file   "test1.c"           /* some assembler directives to be */
18 :     .version    "01.01"         /* ignored */
19 : gcc2_compiled.:
20 : .section    .rodata             /* this segment has read-only data */
21 : .LC0:
22 :     .string "Hello, World\n"
23 : .text
24 :     .align 4
25 : .globl main
26 :     .type    main,@function
27 : main:                           /* main function begins */
28 :     pushl $.LC0                 /* push parameter for printf() on stack */
29 :     call printf                 /* call the function */
30 :     addl $4,%esp                /* clear the stack */
31 : 
32 :     xorl  %eax,%eax             /* make EAX = 0, functions use register */
33 :     jmp .L1                     /* EAX to return values */
34 :     .p2align 4,,7               /* this is an alignment directive */
35 : .L1:
36 :     ret                         /* return from main, done */
37 : .Lfe1:
38 :     /* other assembler directives to be ignored */
39 :     .size    main,.Lfe1-main        
40 :     .ident  "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"
41 : /* end of the generated assembly language file */
42 : /* ---------------------------------------------------------------- */

In case you know about the architecture of the 80386 or higher microprocessors and have experience with assembly language programming, you will find that the assembly language that is produced is only partly familiar to you. This assembly language follows the AT&T assembler syntax that is different from the Intel/Microsoft Assembler/Turbo Assembler syntax that most of us are probably familiar with. Let us go through the assembly language code. We will ignore the assembler directives as they are not crucial towards understanding the generated code. On line 20 a read-only data segment has been defined with the string "Hello, World\n" in it. A label .LC0 has been assigned to the string. On line 27, the code for the main() function begins. As we know, in C language the parameters to functions are passed by pushing them on the stack, and the parameters are pushed in the reverse order i.e. the last parameter is pushed first on the stack. In this case, the printf() function is being called with a single parameter, the string "Hello, World\n". The statement pushl $.LC0 pushes the address of the string "Hello, World\n" on the stack. The "l" in pushl stands for "long" as we are dealing with 32 bit variables. In all the assembly language programs that we will see, the mnemonics will be followed by an "l" to indicate that we are dealing with 32 bit variables. The "$" preceding .LC0 means the address of the string. The next statement calls the printf() function. After the printf() function finishes execution, we need to cleanup the stack, so we need to add 4 to ESP. (Why 4? That's because we pushed 4 bytes on the stack before calling printf().) To do so, we would normally write, ADD ESP, 4. The Intel convention is <instruction> dest, src. However, the AT&T convention is <instruction> src, dest, so you can see that the instruction on line 30 is addl $4, %esp. Immediate operands like 4 are prefixed by a $ and register names are prefixed by a %. This convention was followed to maintain compatibility with the BSD assembler. The next statement XOR's EAX with itself so that EAX = 0 afterwards. This is because the return value from a function is stored in the EAX register. After that, you will see a jump instruction and an alignment directive. These will not be explained and it will suffice to know that main() function will return back at this point. Now that we understand how the assembly language code looks like, let us move towards the optimizations.

3. Constant Folding

Constant folding is the simplest code optimization to understand. Let us suppose that you write the statement x = 45 * 88; in your C program. A non-optimizing compiler will generate code to multiply 45 by 88 and store the value in x. An optimizing compiler will detect that both 45 and 88 are constants, so their product will also be a constant. Hence it will find 45 * 88 = 3960 and generate code that simply copies 3960 into x. This is constant folding, and means the calculation is done just once, at compile time, rather than every time the program is run. To illustrate this, create the file test2.c as shown below. Generate the assembly code for this program as was shown earlier. Since by default, GCC does not optimize the program, you will see that the assembly code is a straightforward translation of the C program (Lines 18 to 62).


 1 : /* test2.c */
 2 : /* Demonstration of constant propagation */
 3 : #include <stdio.h>
 4 : 
 5 : int main()
 6 : {
 7 :     int x, y, z;
 8 :     x = 10;
 9 :     y = x + 45;
10 :     z = y + 4;
11 :     printf("The value of z = %d", z);
12 :     return 0;
13 : }
14 : /* end of test2.c */
15 : 
16 : /* ---------------------------------------------------------------- */
17 : /* assembly language file without any optimizations */
18 :     .file   "test2.c"
19 :     .version    "01.01"
20 : gcc2_compiled.:
21 : .section    .rodata
22 : .LC0:
23 :     .string "The value of z = %d"
24 : .text
25 :     .align 4
26 : .globl main
27 :     .type    main,@function
28 : main:
29 :     pushl %ebp             /* save EBP register on stack */
30 :     movl %esp,%ebp         /* EBP = ESP */
31 :     subl $12,%esp          /* Create stack frame. 3 variables x 4 bytes */
32 : 
33 :     /* x = 10; */
34 :     movl $10,-4(%ebp)      /* x = 10. x is topmost on the stack */
35 : 
36 :     /* y = x + 45; */
37 :     movl -4(%ebp),%edx     /* EDX = x */
38 :     addl $45,%edx          /* EDX = EDX + 45 */
39 :     movl %edx,-8(%ebp)     /* y = EDX. y is second from top of stack */
40 : 
41 :     /* z = y + 4 */
42 :     movl -8(%ebp),%edx     /* EDX = y */
43 :     addl $4,%edx           /* EDX = EDX + 4 */
44 :     movl %edx,-12(%ebp)    /* z = EDX. z is third from top of stack */
45 : 
46 :     /* printf("The value of z = ", z); */
47 :     movl -12(%ebp),%eax    /* EAX = z */
48 :     pushl %eax             /* push EAX(=z) as first parameter of printf */
49 :     pushl $.LC0            /* second parameter for printf */
50 :     call printf                 
51 :     addl $8,%esp           /* clear stack */
52 : 
53 :     /* return 0; */
54 :     xorl %eax,%eax         /* for return 0 */
55 :     jmp .L1
56 :     .p2align 4,,7
57 : .L1:
58 :     leave
59 :     ret
60 : .Lfe1:
61 :     .size    main,.Lfe1-main
62 :     .ident  "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"
63 : /* end of assembly language code */
64 : /* ---------------------------------------------------------------- */
65 : 
66 : /* ---------------------------------------------------------------- */
67 : /* generated assembly language code after optimization */
68 : 
69 :     .file   "test2.c"
70 :     .version    "01.01"
71 : gcc2_compiled.:
72 : .section    .rodata
73 : .LC0:
74 :     .string "The value of z = %d"
75 : .text
76 :     .align 4
77 : .globl main
78 :     .type    main,@function
79 : main:
80 :     pushl %ebp             /* Save EBP register on stack */
81 :     movl %esp,%ebp         /* EBP = ESP */
82 : 
83 :     /* by constant propagation, z will always be 59 */
84 :     /* printf("The value of z = %d", z); */
85 :     pushl $59              /* first printf parameter */
86 :     pushl $.LC0            /* second printf parameter */
87 :     call printf
88 :                            /* no need of cleanup, we are exiting anyway */
89 :     /* return 0; */
90 :     xorl %eax,%eax              
91 :     leave
92 :     ret
93 : .Lfe1:
94 :     .size    main,.Lfe1-main
95 :     .ident  "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"
96 : /* end of assembly language code */
97 : /* ----------------------------------------------------------------- */

There are some new things in the assembly code that we need to understand. First of all, the main() function defines 3 local variables for whom space will be allocated on the stack. Also, to access these variables, we will be using the indexed addressing mode and we will be using EBP for that. So the first statement saves the current value of EBP onto the stack. Then the stack pointer ESP is copied into EBP (note that the source ESP is first) so that EBP can be used for accessing the local variables. Finally, we need to create space for three 4-byte variables on the stack, so we subtract 12 from ESP; i.e., we grow the stack by 12 bytes. x will be the bottom-most stack element and at an offset of -4 from EBP. See the diagram below.


             EBP-----> ---------------
                       |      x      |       4 Bytes
                       ---------------
                       |      y      |       4 Bytes
                       ---------------
                       |      z      |       4 Bytes
             ESP-----> ---------------
                       |             |
                       |             |
                   ^   |             |
                   |         ...
Address increases  |   |             |
as we go up        | 0 ---------------  

Similarly, the offset of y from EBP is -8 and that of z is -12. Now consider the assignment x = 10;. The statement to implement it on line 34 is movl $10, -4(%ebp). The indexed addressing mode is written as <offset>(<base register>). Thus the above statement will copy the constant 10 to the address (EBP - 4) i.e. the address of x on the stack. In a similar manner, -8(%ebp) is used to access y and -12(%ebp) is used to access z. Lines 37, 38 and 39 evaluate x + 45 and assign the result to y. To do so, the value of x is first copied into the EDX register, 45 is added to it and the result which is in EDX is copied to y. The code for z = y + 4 is similar. In line 47 the parameters for printf() are pushed on the stack. The last parameter (z) is pushed first and then the address of the string is pushed. In line 51, we cleanup the stack by adding 8 to ESP. I guess that since we pushed two 4-byte parameters, we had to add 8 to ESP. In the first example, we pushed only one parameter and hence we had to add just 4 to ESP. The rest of the code is easy to understand.

Now if we look at the above program, when we evaluate x + 45, the value of x is always going to be 10 because of the assignment x = 10. Therefore x + 45 will always evaluate to 55. So the statement always assigns 55 to y. Similarly, when evaluating y + 4, the result will always be 59. If the optimization is enabled, the compiler will be in a position to detect this. To enable optimization, use the -O2 option. Enter the following command:

gcc -c -S -O2 test2.c

The assembly code generated with optimization enabled is shown in lines 69 to 95. Notice that on line 85, the compiler directly pushes the constant 59 on the stack followed by the address of the string and calls printf(). Thus, by constant folding, the compiler evaluates the various expressions in the program only once and plugs the final value into the generated code. One more interesting thing to observe is that after constant folding, there is no need of the variables x, y and z. Therefore no space for them is allocated on the stack, thus reducing the memory requirement of the program. This brings out the fact that one optimization may lead to another one. In the above case constant folding lead to a decrease in run time (since all the computations are done at compile time) and also to a decrease in the space requirements.

4. Common Subexpression Elimination

Many a times, it happens that the same expression is evaluated at different places in the same program and the values of the operands in the expression do not change in between the two evaluations of that expression. For example, the program may evaluate say a * b at the beginning and at the end. If the values of a and b do not change in between these two evaluations of a * b, then instead of evaluating a * b again at the end, we can save the result of the evaluation of a * b at the beginning in some temporary variable and use it at the end. This will help eliminate redundant computations in the program. This optimization is called as common subexpression elimination. Consider the following program that demonstrates it.


 1 : /* test3.c */
 2 : /* common subexpression elimination, and also of constant propagation */
 3 : #include <stdio.h>
 4 : 
 5 : int main()
 6 : {
 7 :     int a, b;
 8 :     int x, y, z;
 9 :     scanf("%d %d", &a, &b);
10 :     x = a * b;
11 : 
12 :     if(b >= 4)
13 :     {
14 :         y = a * b;
15 :         z = 0;
16 :     }
17 :     else
18 :     {
19 :         z = a * b * 4;
20 :         y = 0;
21 :     }
22 : 
23 :     printf("x = %d, y = %d, z = %d\n", x, y, z);
24 :     return 0;
25 : }
26 : /* end of test3.c */    
27 : 
28 : /* ----------------------------------------------------------------- */
29 : /* generated unoptimized assembly language code */
30 :     .file   "test3.c"
31 :     .version    "01.01"
32 : gcc2_compiled.:
33 : .section    .rodata
34 : .LC0:
35 :     .string "%d %d"
36 : .LC1:
37 :     .string "x = %d, y = %d, z = %d\n"
38 : .text
39 :     .align 4
40 : .globl main
41 :     .type    main,@function
42 : main:
43 :     pushl %ebp                  /* save EBP */
44 :     movl %esp,%ebp              /* EBP = ESP */
45 :     subl $20,%esp               /* Create space for 5 variables */
46 : 
47 :     /* scanf("%d %d". &a, &b); */
48 :     leal -8(%ebp),%eax
49 :     pushl %eax                  /* push address of b on stack */
50 :     leal -4(%ebp),%eax
51 :     pushl %eax                  /* push address of a on stack */
52 :     pushl $.LC0                 /* push address of string */
53 :     call scanf
54 :     addl $12,%esp               /* stack cleanup after scanf */
55 : 
56 :     /* x = a * b; */
57 :     movl -4(%ebp),%eax          /* EAX = a */
58 :     imull -8(%ebp),%eax         /* EAX = EAX * b = a * b */
59 :     movl %eax,-12(%ebp)         /* x = EAX = a * b */
60 : 
61 :     /* if( b >= 4)... */
62 :     cmpl $3,-8(%ebp)            /* compare b with 3 */
63 :     jle .L2                     /* else part at label .L2, if follows */
64 : 
65 :     /* y = a * b; */
66 :     movl -4(%ebp),%eax          /* EAX = a */
67 :     imull -8(%ebp),%eax         /* EAX = EAX * b = a * b */
68 :     movl %eax,-16(%ebp)         /* y = EAX = a * b */
69 :     /* z = 0; */
70 :     movl $0,-20(%ebp)
71 :     jmp .L3                     /* jump over the else part */
72 : 
73 :     .p2align 4,,7
74 : .L2:
75 :     /* else part begins here */
76 : 
77 :     /* z = a * b * 4; */
78 :     movl -4(%ebp),%eax          /* EAX = a */
79 :     imull -8(%ebp),%eax         /* EAX = EAX * b = a * b */
80 :     leal 0(,%eax,4),%edx        /* EDX = EAX*4 + 0 */
81 :     movl %edx,-20(%ebp)         /* z = EDX */
82 :     /* y = 0; */
83 :     movl $0,-16(%ebp)
84 : .L3:
85 :     /* if..else is over here */
86 : 
87 :     /* printf("x = %d, y = %d, z = %d\n", x, y, x); */
88 :     movl -20(%ebp),%eax
89 :     pushl %eax                  /* push address of z on stack */
90 :     movl -16(%ebp),%eax
91 :     pushl %eax                  /* push address of y on stack */
92 :     movl -12(%ebp),%eax
93 :     pushl %eax                  /* push address of x on stack */
94 :     pushl $.LC1                 /* address of string */
95 :     call printf
96 :     addl $16,%esp               /* stack cleanup after printf */
97 : 
98 :     /* return 0 */
99 :     xorl %eax,%eax
100 :     jmp .L1
101 :     .p2align 4,,7
102 : .L1:
103 :     leave
104 :     ret
105 : .Lfe1:
106 :     .size    main,.Lfe1-main
107 :     .ident  "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"
108 : /* end of unoptimized assembly language code */
109 : /* --------------------------------------------------------------- */
110 : 
111 : /* --------------------------------------------------------------- */
112 : /* generated optimized assembly language code */
113 :     .file   "test3.c"
114 :     .version    "01.01"
115 : gcc2_compiled.:
116 : .section    .rodata
117 : .LC0:
118 :     .string "%d %d"
119 : .LC1:
120 :     .string "x = %d, y = %d, z = %d\n"
121 : .text
122 :     .align 4
123 : .globl main
124 :     .type    main,@function
125 : main:
126 :     pushl %ebp               /* save EBP */
127 :     movl %esp,%ebp           /* EBP = ESP */
128 :     subl $8,%esp             /* space for just 2 variables on stack */
129 : 
130 :     /* scanf("%d %d", &a, &b); */
131 :     leal -4(%ebp),%eax
132 :     pushl %eax               /* push address of b on stack */
133 :     leal -8(%ebp),%eax
134 :     pushl %eax               /* push address of a on stack */
135 :     pushl $.LC0              /* address of string */
136 :     call scanf
137 : 
138 :     /* x = a * b; */
139 :     movl -4(%ebp),%eax       /* EAX = b */
140 :     movl %eax,%edx           /* EDX = EAX = b */
141 :     imull -8(%ebp),%edx      /* EDX = EDX * a = b * a = a * b */
142 : 
143 :     addl $12,%esp            /* delayed stack cleanup */
144 :     /* if( b >= 4).... */
145 :     cmpl $3,%eax             /* compare EAX = b with 3 */
146 :     jle .L17                 /* else part from label .L17 */
147 : 
148 :                              /* y stored in ECX, z in EAX, x in EDX */   
149 :     /* y = a * b; */
150 :     movl %edx,%ecx
151 :     /* z = 0; */
152 :     xorl %eax,%eax
153 :     jmp .L18                 /* jump over the else part */
154 :     .p2align 4,,7
155 : .L17:
156 :     /* z = a * b * 4; */
157 :     leal 0(,%edx,4),%eax     /* LEA EAX, [EDX*4]+0 */
158 :     /* y = 0; */
159 :     xorl %ecx,%ecx
160 : .L18:
161 :     pushl %eax               /* push value of z */
162 :     pushl %ecx               /* push value of y */
163 :     pushl %edx               /* push value of x */
164 :     pushl $.LC1              /* push address of string */
165 :     call printf
166 :     /* stack cleanup after printf not necessary */
167 : 
168 :     /* return 0; */
169 :     xorl %eax,%eax
170 :     leave
171 :     ret
172 : .Lfe1:
173 :     .size    main,.Lfe1-main
174 :     .ident  "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"
175 : /* end optimized assembly code */
176 : /* -------------------------------------------------------------- */

This program has an example of a common subexpression. On line 10, the expression a * b is evaluated the first time, and then again on lines 14 and 19. The last two evaluations of a * b are redundant since the value of neither a nor b changes after the first evaluation. Thus these two evaluations are common subexpressions that can be eliminated. Lines 30 to 108 show the unoptimized assembly code that is a straightforward translation of the C code and should be easy to understand. Now consider the optimized assembly language code from lines 113 to 176. The first thing to notice is that now only variables a and b are stored on the stack, hence a stack of just 8 bytes is required as opposed to a 20 byte stack for the unoptimized version. You may wonder what's so special about variables a and b. The specialty is that the address of variables a and b is used in the program (for scanf()) and variables that reside in the registers cannot have a memory address. Hence the compiler is unable to put them inside the registers. The registers that the compiler chooses for other variables are as follows: x in EDX, y in ECX and z in EAX. Statements 139 to 141 evaluate a * b and the value is stored in EDX (which holds x). Also, the value of b is available in the register EAX. One more thing to notice is the delayed cleanup of stack after the call to scanf() on line 143. May be there is some advantage in doing so, I don't know.

Next starts the if statement. In the if part, the expression a * b is reevaluated and we expect that the compiler will use the value stored in EDX. That is exactly what the compiler does. For the statement y = a * b, the generated code on line 150 simply copies the value of a * b in register EDX into the register ECX (which holds y). In the else part again, there is a common subexpression in the statement z = a * b * 4. Thus we expect that the compiler will take the value of a * b in EDX, multiply it by 4 and then store the result in EAX (which holds z). Now there are many ways in which this can be done. One is to use a sequence of movl, imull instructions as in


    movl %edx, %eax         /* EAX = EDX  = a * b */
    imull $4, %eax          /* EAX = EAX * 4 */

The second choice is to use a shift (sall) instead of imull in the above sequence of instructions. However, it turns out that the GCC uses an obscure speed trick to optimize the code. It uses the instruction


    leal 0(,%edx,4), %eax

This instruction uses the scaling and indexing capabilities of the 80386 processors. The above instruction takes EDX as the index register, 4 as the scale and 0 as the offset, calculates the effective address and stores it in the EAX register. Thus the register EAX gets a value EDX(=a*b)*4 + 0 i.e. a * b * 4. The leal instruction always executes in 2 clock cycles on an 80386, whereas a simple shift will take around 7 clock cycles. We see that the compiler knows about processor peculiarities and uses it when it generates the code.

Thus it can be seen that common subexpressions save a lot of computations and also space that is used up by the code for these redundant computations. At this stage, one can understand that the compiler when analyzing the program for optimization must keep a track of how and when the variables change, the expressions that are evaluated and also which registers are allocated to variables. In general such a kind of analysis that the compiler performs on the program is called as data flow analysis.

5. Dead Code Elimination

Dead code is the code in the program that will never be executed for any input or other conditions. A common example is an if statement. If the compiler finds out that the condition inside the if is never going to be true, then the body of the if statement will never be executed. In that case, the compiler can completely eliminate this dead code, thus saving the memory space occupied by the code. The following program demonstrates dead code elimination.


 1 : /* test4.c */
 2 : /* demonstration of dead code elimination */
 3 : #include <stdio.h>
 4 :
 5 : int main()
 6 : {
 7 :     int x;
 8 :
 9 :     scanf("%d", &x);
10 :
11 :     if(x < 0 && x > 0)
12 :     {
13 :         x = 99;
14 :         printf("Hello. Inside the if!!!");
15 :     }
16 :
17 :     return 0;
18 : }
19 : /* end of test4.c */
20 :
21 : /* --------------------------------------------------------------- */
22 : /* optimized assembly code */
23 :     .file   "test4.c"
24 :     .version    "01.01"
25 : gcc2_compiled.:
26 : .section    .rodata
27 : .LC0:
28 :     .string "%d"
29 : .LC1:
30 :     .string "Hello. Inside the if!!!"
31 : .text
32 :     .align 4
33 : .globl main
34 :     .type    main,@function
35 : main:
36 :     pushl %ebp             /* save EBP on stack */
37 :     movl %esp,%ebp         /* EBP = ESP */
38 :     subl $4,%esp           /* create space for x on the stack */
39 :
40 :     /* scanf("%d", &x); */
41 :     leal -4(%ebp),%eax
42 :     pushl %eax             /* push address of a on stack */
43 :     pushl $.LC0            /* push string on stack */
44 :     call scanf
45 :
46 :     /* the entire body of the if and the condition checking is dead code */
47 :     /* return 0; */
48 :     xorl %eax,%eax         /* no stack cleanup, we are exiting anyway */
49 :     leave
50 :     ret
51 : .Lfe1:
52 :     .size    main,.Lfe1-main
53 :     .ident  "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"
54 : /* end optimized assembly code */
55 : /* ---------------------------------------------------------------- */

Since the unoptimized assembly language code serves no purpose and also its easy to understand, I have omitted it. In the program, the condition on line 11 is x < 0 && x > 0, which can never be true. The compiler finds this and concludes that the body of the if statement forms dead code, so it does not generate any code for that. One interesting thing to notice is that after the body of if has been eliminated, the string "Hello. Inside the if!!!" is no longer needed and hence can be eliminated from the read-only data section. However, detection of such things probably will increase the complexity of the compiler and hence is not done.

6. Strength Reduction using Induction Variable

One type of code optimization is strength reduction in which a "costly" operation is replaced by a less expensive one. For example, the evaluation of x2 is much more efficient if we multiply x by x rather than call the exponentiation routine. One place where this optimization can be applied is in loops. Many times in a loop, one variable changes in synchronization with the loop variable. Such a variable is called as induction variable. Induction variables give the compiler a chance to apply strength reduction, as can be seen from the following program.


 1 : /* test5.c */
 2 : /* demonstration of induction variable elimination */
 3 : int main()
 4 : {
 5 :     int i, j;
 6 :
 7 :     for(i = 0; i < 10; i++)
 8 :     {
 9 :         j = i * 7;
10 :         printf("i = %d, j = %d", i, j);
11 :     }
12 :     return 0;
13 : }
14 : /* end test5.c */
15 :
16 : /* --------------------------------------------------------------- */
17 : /* optimized assembly language code */
18 :     .file   "test5.c"
19 :     .version    "01.01"
20 : gcc2_compiled.:
21 : .section    .rodata
22 : .LC0:
23 :     .string "i = %d, j = %d"
24 : .text
25 :     .align 4
26 : .globl main
27 :     .type    main,@function
28 : main:
29 :     pushl %ebp                  /* save EBP on stack */
30 :     movl %esp,%ebp              /* ESP = EBP */
31 :
32 :     pushl %esi                  /* ESI will hold 'j' */
33 :     pushl %ebx                  /* EBX will hold 'i' */
34 :     xorl %ebx,%ebx              /* both are initialized to zero */
35 :     xorl %esi,%esi
36 :     .p2align 4,,7
37 : .L5:
38 :     /* printf("i = %d, j = %d", i, j); */
39 :     pushl %esi                  /* push value of j */
40 :     pushl %ebx                  /* push value of i */
41 :     pushl $.LC0                 /* push address of string */
42 :     call printf
43 :     addl $12,%esp               /* stack cleanup */
44 :
45 :     /* instead of saying j = i * 7, its efficient to say j = j + 7 */
46 :     addl $7,%esi
47 :     incl %ebx                   /* i++ */
48 :     cmpl $9,%ebx                /* is i <= 9, then repeat the loop */
49 :     jle .L5
50 :
51 :     /* return 0; */
52 :     xorl %eax,%eax
53 :     leal -8(%ebp),%esp
54 :     popl %ebx
55 :     popl %esi
56 :     leave
57 :     ret
58 : .Lfe1:
59 :     .size    main,.Lfe1-main
60 :     .ident  "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"
61 :
62 : /* end optimized assembly code */
63 : /* ----------------------------------------------------------------- */

Here i is the loop variable whereas j is the induction variable as j always changes in lock step with i. In the generated assembly language code, the compiler has decided to use registers to store both i and j with i in EBX and j in ESI. Line 34 initializes EBX(=i) to zero, as is indicated in the initialization part of the for loop. The compiler sees that during the first pass, j will be assigned a value of 0, so it also initialized ESI to 0 in line 35. The loop starts at line 37 and continues till line 49. Since j already has its value assigned to it, the first thing the compiler does inside the loop is to call the printf() function. Here, the compiler has adjusted the order of the statements in the loop so as to enable it to use strength reduction. After analyzing the program, the compiler sees that inside the loop, the value of i is always going to increase by 1 and since j is an induction variable, its value is always going to increase by 7. Therefore, instead of multiplying i by 7 (which is costly), it adds 7 to the old value of j before going on to the next iteration. Thus a costly operation of multiplication has been replaced by addition which is cheaper (in terms of time).

7. Conclusion

In this article we have seen some very basic code optimization techniques that the GNU C Compiler uses to optimize the generated code. From these optimization techniques and the various pieces of information that are required to apply them, the reader can appreciate the type of sophisticated and complex analysis that the compiler must carry out on the program. It has to keep track of various things like variables, their storage places (memory or registers), expression evaluations, constant expressions, dead code etc. It is because of this high complexity of the process that the compiler takes much longer to compile a program with optimization enabled. There are many details that are involved in code optimization and code generation that I have not explained and that I don't know. Code optimization is a field of active research and interested readers can refer to [1] for additional information.

8. Acknowledgments

I would like to thank my Bachelor's project guide Dr. Uday Khedker for creating my interest in compilers and code optimization. I would also like to thank the Linux Gazette, Linux Documentation Project, PC Quest and the Pune Linux User's Group (http://www.pluggies.org) which have earlier accepted and published my contributions that inspires me to write more.

9. References

  1. Compilers: Principles, Techniques, and Tools, A.V.Aho, Ravi Sethi and J.D.Ullman, Addison Wesley.
  2. Systems Programming and Operating Systems, D.M.Dhamdhere, Tata McGraw-Hill.
  3. Assembly HOWTO, Franois-Ren Rideau, Linux Documentation Project.
  4. Advanced 80386 Programming Techniques, James L. Turley, Osborne McGraw-Hill.

Rahul U Joshi

I have recently joined Veritas Software India Pvt. Ltd. as an Associate Software Engineer. I have worked on a research project entitled "Node Listing Based Global Data Flow Analysis" during my Bachelor's degree. I am interested in compilers, programming languages, operating systems and parallel/distributed processing. I have contributed articles to Linux Gazette about parallel processing and about optimizing C.


Copyright © 2001, Rahul U Joshi.
Copying license http://www.linuxgazette.com/copying.html
Published in Issue 71 of Linux Gazette, October 2001

"Linux Gazette...making Linux just a little more fun!"


The Foolish Things We Do With Our Computers

By


On September 6, I, um, dropped a fork on my hard drive while it was running. I asked The Answer Gang and Nick Moffitt what other foolish things they've done with their computers, and here are the responses.

The Case of the Dropped Fork

I keep my computer's cover open to avoid overheating. A fork fell off my desk, through the computer case and landed on the hard drive. The other half of the fork landed on the, um, power supply. Fortunately not *in* the power supply. :) I extracted the fork--being glad I didn't get a shock--and then discovered I couldn't save my nedit files ("read-only file system"). The disk light stayed on continuously. I ran 'mount' and got an input/output error. Suspecting the drive was fried, I wrote down all the changes I'd made to my Python files in the nedit windows. I tried "su -c mount /Backups" to mount my backup partition on the other drive, but it wouldn't do anything. I got most of the way through writing down my changes when nedit aborted. I closed what I could and tried to quit the X session, but the computer froze. I pressed Reset, but it wouldn't get past the BIOS. I turned off the computer, waited a bit, and turned it back on. This time it booted OK. :) :)

The computer ran for a couple days, then then it started crashing in the middle of the night and on bad days I would get two Oopses a day. My roommate strongly hinted I fix my computer, because he works at night and depends on it being the Internet gateway for his Windows boxen. I wanted to install ROCK Linux and try it out, so this gave me an excuse. But I couldn't get through the installation routine without an Oops. It didn't matter whether both HDs were connected or only one. Thinking something unknown might be wrong with the computer besides just the hard drive, I got the parts to build another computer: AMD Duron 800 (more than twice as fast as my K6 350 woohoo!), the cheapest brand-name HD (10 GB), and a PCI Ethernet card and sound card (because my new motherboard didn't have ISA slots), and an ATX case. Next month, I'll write about my adventures installing ROCK.


The Viking Ship

By

I haven't got any blunder stories for you, but here's something we used to do with computer hardware back in high school:

My brother's school at the time had a bunch of surplus IBM model Bs (predecessor of the XT I think) that I took home. I only had so many outlets in my room (I had used up all the plugs I dared, and was using oil lamps to light the place, but that's another story), so I had no use for most of them myself.

My friend Jason had a bunch of clock-chip crystals from some card that ran at 66MHz or something. He probably got them from Boeing Surplus, where you can buy drill bits by the pound, hard hats for a dollar, and Ultrasparc pieces as-is. At least, that was the way it used to be.

So we built a crude Viking ship out of spare plywood and set a model B atop it. I ran an extension cord out into the yard to power it, Jason inserted the crystal, and we watched, entranced, as the poor 4.77MHz chip slowly slagged itself. It smelled to high heaven, and the boat didn't catch on fire, so we resorted to setting flaming peeps adrift in his bathtub for our Viking funerals.

"What do you suppose the reaction will be once they reach Valhalla?" Jason asked.

"OLAF LOOK! BUN-NY!" <stomp> <squish>

Iron writes:

When I worked at an ISP, we got our servers from the Boeing Surplus. The owner would buy ten of them at once, whatever model they were selling at $30 each including monitor. The first time, it was these miscellaneous stray 386s. Two years later, it was Dell 486s.

At Bumbershoot (a multi-arts festival every Labor Day weekend), in the art exhibit was a set of ferry-boat models made out of driftwood with scrounged parts, with white Christmas lights inside. They actually looked pretty cool.


Upgrade Hell

By

Gosh, so many years in computing, hard to think what was the dumbest thing... oh yeah, we can narrow it down to just Linux.

Heh.

I think the dumbest thing I've done with my laptop is upgrade it all in one day before I needed it for something... but doesn't everyone do THAT? Face it, upgrades are dangerous.

But you know, if you ate whole herrings like Tux you wouldn't have had that fork bomb.

<badum Ching!>


I/O Cards

By

My dumbest computer act was unplugging and reinserting I/O cards in my S-100 (CP/M) system because I didn't want to wait that long 3-second duration for CP/M to reboot when I was fixing my hardware. After about 40 Acts of Boldness, I finally plugged in the I/O card not quite so straight into the socket and there were lots of sparks.

I just took it apart, and after two weeks (front panel dangling on the floor), I decided to fix the thing. One killer, though. The computer would randomly crash and the front panel lights (it was an Altair 8800 with an 18-slot motherboard), would just light up. After 4 months, when it got in one of its moods, I got a frequency counter and saw that the system clock was superposed where it should not have been. Looking up the signal definitions and the connector pinouts, I saw that there was a piece of copper (from my hot-swapped I/O card connector fingers) shorting the system clock to some other pin (I cannot remember the signals except that one of them was the bus clock). Yes I was electronically oriented (a real computer hacker), and that's what made me so careless.

Not only that, but I was unplugging and reinserting the I/O card without removing power from the computer. How cool I was!

writes:

Hmm, you just dated yourself [about the Altair 8800]--and to join you, I'll admit that I remember those! I think it was the same model Altair that one of my college classes was assigned to write a low-pass filter algorithm for--assembler debugging was a bear, as programming tools were non-existent--at least for us.

Chris writes:

Those were the days of CP/M. But, now we have Linux, so that we have those days and more!

Iron writes:

Especially with all those emulators Linux has.

John writes:

I still have a 486 / 100 on which I ran Slackware. Although I haven't used it in a while, it actually runs X tolerably well, thanks to the SCSI HD.

I just wish they would offer SCSI on laptops - every time my system does a disk buffer flush, there's a short and noticeable pause if I happen to be moving the cursor around the screen to remind me that I'm running an IDE HD. IMO, using a SCSI HD yields a gain similar to having ample RAM in the machine - helps smooth things out.

Iron writes:

What does "superposed" mean? [Regarding the system clock that was superposed where it should not have been.]

Chris writes:

I read too many linear systems books. Some books will call the term superposed, and other books will call the term superimposed (more intuitive). Anyway, it means one mathematical function algebraically summed with another mathematical functions. For example, you might have a 5 volt DC signal with a 240 millivolt sinusoidal signal riding on top of the 5 volt signal. So, you would have a sine wave with an amplitude of 240 millivolts and a DC offset of 5 volts.

I suspect that you understand what I just said. You were probably wondering where the heck I concocted a word such as "superpose". Usually the word is used in the context of superposition with respect to a linear system. I'm not gonna start talking about superposition, because you will probably kill me for rambling (again).

Anyway, I saw a 1-MHz signal appearing where it shouldn't have been. I'm sorry -- I talk so much. Get me talking about science and stuff and I ramble......

Iron writes:

I figured it meant the same thing as superimposed. I just couldn't, with my puny understanding of electronics, figure out how a system clock could "superimpose" itself somewhere, or why it would matter.

Chris writes:

Oh, now I understand. Utilizing my puny mind, I got bold and was unplugging circuit boards (and plugging them back into the motherboard) with the power on the computer! After fixing my fried computer, every now and then, I could not boot up the computer. All of the front panel lights, on the Altair 8800 computer, just lit up (abnormally). When I finally fixed the problem, I saw that there was a piece of copper short-circuiting the system clock signal to an adjacent pin inside one of the card edge connectors (These were 100-pin connectors - thus, the S-100 bus).

The piece of copper was a portion of foil that got sort of torn off from the edge connector of the I/O card that I was constantly removing and plugging into the computer.


Cold Therapy

By

I do this (Sorta) all the time with my PCs (currently). I have only one floppy drive. So when I need to use it on any system (Linux systems or my OS-challenged systems), I just hot-swap it in.. power, I/O cables and all!

Reason: Just like you, I don't want to wait. The Challenged OS takes 7 minutes to boot, linux only takes like less than two (But I lose my uptime longevity).

The most foolish thing I've done? Has got to be when I had a 386 CPU that would overheat and crash the system due to my power supply fan had gone out. So three or four times daily I would take 2 zip lock bags and fill them with ice cubes and put them IN the computer right on top of the CPU. It actually worked very well until I was able to buy a new system.

BTW, I still have that same 386/33 motherboard. Was going to make it a Linux Router, till I found the LinkSYS router.

Iron writes:

That takes the cake! If I could draw, I'd make a picture of a computer with melting ice cubes in it.

Leaky Laptop

By

As recently as this past Spring I put my laptop into a backpack to bring to a friend's house along with some other things, one of which was ... a water bottle. Well, the top wasn't really screwed onto the bottle very securely, and ... you can guess what happened. When I arrived at my destination and pulled the backpack out of the car, I noticed that the seat was very damp. Upon checking the contents of the backpack and removing the laptop, water sort of dripped out of the side of the machine as I held it sideways / vertical.

I took it inside and disassembled it partially, and left it on a table with a fan blowing into it. The important thing to remember in such cases is not to turn on the machine (or other electronic device)! After I took it home I removed the mobo and left it over-night. Luckily, the machine survived the ordeal, without damage to the HD. The screen showed a few white spots, but those went away after a few weeks - sigh of relief. I was just glad that it was the older laptop and not the one I had just bought a week before.

Iron writes:

That's another picture I'd draw: a laptop with water dripping out the side.

If you would like to tell us about the most foolish thing you've done with your computer, maybe we'll publish it.

Mike Orr

Mike ("Iron") is the Editor of Linux Gazette. You can read what he has to say in the Back Page column in this issue. He has been a Linux enthusiast since 1991 and a Debian user since 1995. He is SSC's web technical coordinator, which means he gets to write a lot of Python scripts. Non-computer interests include Ska and Oi! music and the international language Esperanto. The nickname Iron was given to him in college--short for Iron Orr, hahaha.


Copyright © 2001, Mike "Iron" Orr.
Copying license http://www.linuxgazette.com/copying.html
Published in Issue 71 of Linux Gazette, October 2001

"Linux Gazette...making Linux just a little more fun!"


Qubism

By


qb-10th-s.jpg
qb-longday-s.jpg
qb-rsync-s.jpg
qb-wordprocessor-s.jpg
qb-worms-s.jpg
qb-iiscrack-s.jpg
qb-leanbeef-s.jpg
qb-stuffed-s.jpg
qb-xonipaq-s.jpg

Jon "SirFlakey" Harsem

Jon is the creator of the Qubism cartoon strip and current Editor-in-Chief of the CORE News Site. Somewhere along the early stages of his life he picked up a pencil and started drawing on the wallpaper. Now his cartoons appear 5 days a week on-line, go figure. He confesses to owning a Mac but swears it is for "personal use".


Copyright © 2001, Jon "Sir Flakey" Harsem.
Copying license http://www.linuxgazette.com/copying.html
Published in Issue 69 of Linux Gazette, August 2001

"Linux Gazette...making Linux just a little more fun!"


Numerical Workbenches, part III

By


Parts I and II of this little series on numerical math workbenches on GNU/Linux have covered rather dry subjects like matrix manipulations and for-loops. This part brings more color to the screens as it turns to the graphical capabilities of GNU/Octave, Scilab, and Tela. It will deviate from the previous way of presenting the three applications, because the differences of the graphical backends are far too big to allow for a uniform treatment with only a few explanations on the differences.

The article starts with an introduction applicable to all programs. To give the reader maximum benefit, all applications have to solve the same three real life problems. This simplifies the comparison despite the differences of the implementations. In the last part, Octave, Scilab, and Tela have to tackle the given tasks.

Introduction

Discrete Data Only
As all three applications are designed to work with vectors and matrices, their graphics backends only understand this kind of data. Doh! For the user this means that the graph of a mathematical function like
                { sin(x)/x  for x <> 0
    y := f(x) = {
                {    1      for x == 0

cannot be drawn from the above expression, but the function has to be transformed into discrete pairs (x(i)y(i)). This transformation is called sampling. To sample f(x), we pick values x where we are interested in f(x) and compute f for the given x. Any reader who has followed the earlier parts, will immediately recognize that this involves a vector operation.

    ### GNU/Octave code
    function y = f(x)
        if x == 0.0
            y = 1.0;
        else
            y = sin(x) ./ x;
        endif
    endfunction
    x = linspace(0.0, 4*pi, 50);
    y = f(x);

linspace(start, end, n) returns a vector from start to end, whose n elements are evenly spaced. The vectors x and y can be passed to an appropriate plotting function.

If data already are in vectorized form, they can be displayed immediately.

Complexity at Large
How do we actually display a graph? This question leads us to the fundamental problem all applications run into when it comes to graphical output of data: either complicated or many simple function calls! Let us first consider the complexity for the user of a call to solve a system of linear equations
    x = a \ b             # Octave, Scilab

or

    x = linsolve(a, b)    // Tela

Even if we try hard to artificially complicate the calls (yet leaving them useful), we hit the end of the road at

    x = linsolve(a, b, "CompletePivoting", "DoIterativeRefinement")

This is, with the two additional parameters -- pivoting strategy and iterative refinement of the solution -- the user completely controls linsolve(). All other ``decisions'' can reasonably be taken by the workbench itself, for example, what algorithm to use if matrix a has a special form.

Contrast this with the 2d-graph of

    x = [2.25,  2.27,  2.42,  ...]
    y = [0.363, 0.360, 0.337, ...]

What options can we think of?

  • Draw isolated data points or connect data points with straight lines.
  • Which symbol to draw at each data point? A dot, star, circle, or asterisk? What color should the data points be?
  • Which kind of line to draw between the data points? Continuous, dashed, dotted, or dash-dotted? What line thickness and what color is the line?
  • Scale the plot to fit within the plotting window?
  • Draw coordinate axes? Linear or logarithmic x or y axis? Both axes logarithmic?
  • Graduate or annotate the axes?
  • ...

Many more reasonable options are conceivable. The point is: we cannot expect plotting to be as simple to use as is for example solving a system of linear equations -- not because the applications are badly written, but because the topic is inherently more complicated on the user's side. Hence, nobody should be surprised if she ever needs 20 or more lines to define a publication quality plot in Octave, Scilab, or Tela.

Problems

To make the competition interesting, I put up problems, which are not too far away from the Real World(tm). Each of the three applications will have to cope with three different types of plots:

  1. 2D Plot of Discrete Data

    Display three sets of data (l1.ascii, l2.ascii, l3.ascii) on a single page. The sets have a different number of data points.

    The data are stored as two columns, column 1 holds the x-value, and column 2 the y-value:

        0.2808  3.419E-07
        0.3711  3.459E-07
        0.4882  3.488E-07
        ...
    

    The graph must show title, axes captions, and legend. The x and y ranges are supplied by the user.

  2. 3D Plot of a Function
    Plot Rosenbrock's function (in two dimensions)
        f(u, v) = 100*(v - u^2)^2 + (1 - u)^2
    

    as a 3d-surface in the parameter ranges -3 <=  u <= 3 and -2 <=  v <= 4.

    Annotate the plot with title and axes captions.

  3. Contour Plot of a Function
    Plot function
        g(u, v) = exp(u) * (4*u^2 + 2*v^2 + 4*u*v + 2*v + 1)
    

    with contours, this is, f(u, v) = z for given z in the parameter ranges -4.5 <= u <= -0.5 and -1 <= v <= 3.

    The iso-lines are defined by a user-specified ``weight'' function.

                              (  z - z_0  ) 3
        z_iso = (z_1 - z_0) * ( --------- )   + z_0
                              ( z_1 - z_0 )
    

    where z_0 and z_1 are the minimum and maximum values of g(u, v) in the plot's range.

    Again, annotate the plot with title and axes captions.

All graphics must be rendered for two devices,

Octave

You know Gnuplot? Then learning to use GNU/Octave's plot functions will be a piece of cake. All you need to do is precede the Gnuplot commands with a ``g'' to reach at the Octave equivalent. -- Oh, you haven't tried Gnuplot yet? Then I will guide you through the examples. However, having a Gnuplot manual (online or dead-tree edition) ready may be helpful.

If you do not want to download Gnuplot's manual, you can use one of the publicly accessible versions.

Octave: 2D Discrete Data Plot

For an easier discussion, I have split the code into blocks. Each block gathers commands that belong together. The blocks are labeled with numbers in square brackets, to allow for referencing them in the text.

    ### [1] Read data set_i into N_i-times-2 matrices
    set1 = load("l1.ascii");
    set2 = load("l2.ascii");
    set3 = load("l3.ascii");
    ### [2] Reset Gnuplot
    graw("reset;");
    clearplot;
    ### [3] Define decorations and plot area
    gset title "Comparison of sets L1, L2, and L3";
    gset xlabel "Temperature / K";
    gset ylabel "Voltage / V";
    gset key top left;
    gset xrange [0 : 100];
    gset yrange [8e-8 : 2e-6];
    ### [4] Plot data
    hold on;
    gplot set1 title "Set L1" with points;
    gplot set2 title "Set L2" with points;
    gplot set3 title "Set L3" with points;
    hold off;
    ### [5] Switch to PostScript output and plot into file
    gset terminal push;
    gset terminal postscript;
    gset output "oct1.eps";
    replot;
    gset terminal pop;
    gset output;

[Graphics: The Gnuplot window that has been opened by Octave's graphics commands shows the three data sets. The data points are drawn with blue, green, and red markers. The markers themselves have different shape. The plot has a title. Both axes show the annotations as defined by the gset-commands.] The output to the Postscript terminal, block [6], produced a printable version (eps) of the graphics.

Block [1] should be clear from the previous articles. The first interaction with Gnuplot happens in [2], where Gnuplot is reset to a known state and the X11-plot window gets cleared. A known state is helpful when still experimenting with Gnuplot's options. In our case reseting is unnecessary, but it does not hurt.

The block of gset commands, [3] is self explaining except

    gset key top left

which means: ``put the legend (or key) inside the plotting area at the north-west corner''. xrange and yrange with their special interval syntax set the width and height of the plot range.

Now, the actual data can be rendered into the plot window [4]. Because the data sets have different sizes, they cannot be gathered in a single matrix. Hence, each data set must be plotted by itself, and Gnuplot must be told -- with hold on -- that it should collect all gplot commands until the last plot of the set is completed and hold off is called. The calls to gplot essentially contain the data matrix

    gplot set1

The title, which shows up in the plot's legend, is assigned in the call to gplot, too.

Block [5] is specific to the way Gnuplot works. For each plot it uses a terminal and an output file (remember that in UN*X everything is a file, as for example is the console). When Gnuplot is running under X, the terminal type defaults to X11 and output file defaults to Gnuplot's X11-graphic window. Both, terminal and output file can be changed independently with gset commands. Thus, to get the same graphics in a different format, we switch from the current terminal to Postscript, and put an ordinary file's name at the output. Function replot replays all plot commands for us, we do not have to write them again. After that the terminal and output settings are undone, which is optional, but helpful if the user wants to twiddle some more gset's and repeatedly check their influence on the graph's appearance.

Octave: 3D Function Plot

    ### [1] Define function
    function z = f(u, v)
        ## truncated Rosenbrock function
        z = 100.0*(v - u.^2).^2 + (1.0 - u).^2;
        zv = z(:);
        zv(find(zv > 100.0)) = 100.0;
        z = reshape(zv, size(z));
    endfunction
    ### [2] Sample function f()
    x = linspace(-3, 3, 40);
    y = linspace(-2, 4, 40);
    [xx, yy] = meshgrid(x, y);
    z_splot = splice_mat(xx, yy, f(xx, yy));
    ### [3] Reset Gnuplot
    graw("reset;");
    clearplot;
    ### [4] Define decorations and viewing direction
    gset data style line;
    gset title "Rosenbrock Function";
    gset xlabel "u";
    gset ylabel "v";
    gset view 30, 160;
    gset hidden;
    gset nokey
    gset parametric;
    ### [5] Plot
    gsplot z_splot;
    ### [6] Switch to PostScript output and plot into file
    gset terminal push;
    gset terminal postscript;
    gset output "oct2.eps";
    replot;
    gset terminal pop;
    gset output;
    gset noparametric;
    system("gzip --best --force oct2.eps");

[Graphics: The Gnuplot window shows a red-mesh that is 'deformed' according to function f(u, v). The whole plot looks like the imprint of a boomerang.] A printer-ready version (eps.gz) is available, too.

Again the first block, [1], should be easy to understand for anyone who has read Part 1 and 2 of this series for it only uses known functions. In contrast, [2] introduces two new functions. Out friend linspace() quickly generates two vectors which will define where f(u, v) will be evaluated: from vectors x and y, a grid is constructed, this is, two matrices xx and yy, where each pair of matrix elements (xx(i, j), yy(i, j)), 1 <= ij <= 40, define a (grid-) point at which function z = f(u, v) will be evaluated. The matrix of all z-values at the grid points then simply is zz = f(xx, yy). However, we are not done at this point, because Octave requires to pass a specially formatted matrix to the 3d-plot function gsplot.

The user-defined function splice_mat() does exactly the needed operation: collect the grid data xx and yy along with the z-values in matrix  z_plot. Matrix z_plot can be handed over to gsplot without further ado (given Gnuplot is in parametric mode. (we will be in parametric mode and for the given kind of problem parametric mode is the only way to go (and I don't want to introduce another level of parenthesis (really!))))

Block [4], a collection of gsets, looks almost familiar. Some new settings are

After so much preparation, the actual plot command, gsplot z_splot in [5] looks trivial.

The Postscript block [6] is similar to [5] in Section ``Octave: 2d discrete data plot''. The only additional job [6] does is gzipping the eps-file. In general system(``shell-commands'') executes shell-commands in a sub-shell. Obviously, this is extremely useful when interacting with an external application, like gzip(1).

Octave: Contour Function Plot

    ### [1] Define function
    function z = g(u, v)
        z = exp(u) .* (4.0*u.^2 + 2.0*v.^2 + 4.0*u.*v + 2.0*v + 1.0);
    endfunction
    ### [2] Define weight function for iso-line distances
    function y = pow_weight(x, n)
        ## Map interval X onto itself, weight with N-th power.
        d = max(x) - min(x);
        y = d*((x - min(x))/d).^n + min(x);
    endfunction
    ### [3] Sample function g()
    x = linspace(-4.5, -0.5, 40);
    y = linspace(-1.0, 3.0, 40);
    [xx, yy] = meshgrid(x, y);
    zz = g(xx, yy);
    z_splot = splice_mat(xx, yy, zz);
    ### [4] Compute iso-line distances
    iso_levels = pow_weight(linspace(min(min(zz))*1.01, ...
                                     max(max(zz))*0.99, 12), 3.0);
    il_str = sprintf("%f,", iso_levels);
    il_str = il_str(1 : length(il_str)-1);    # remove last ","
    ### [5] Reset Gnuplot
    graw("reset;");
    clearplot;
    ### [6] Define decorations and viewing direction
    gset data style line;
    gset title "Contour Plot of g(u, v)";
    gset xlabel "u";
    gset ylabel "v";
    gset contour base;
    gset nosurface;
    gset view 0, 0;
    eval(sprintf("gset cntrparam levels discrete %s", il_str));
    gset parametric;
    ### [7] Plot
    gsplot z_splot;
    ### [8] Switch to PostScript output and plot into file
    gset terminal push;
    gset terminal postscript;
    gset output "oct3.eps";
    replot;
    gset terminal pop;
    gset output;
    gset noparametric;

[Graphics: The Gnuplot window shows 12 iso-lines each with a different color. The plot exhibits a saddle point of g(u, v) in the right third of the image.] A printable version (eps) is available, too.

After working through the 2d discrete and the 3d function plot examples, the top three blocks [1-3] of the contour function script should not raise many questions. In block [4] however, I have to prepare a trick, which I must play at the end of block [6]. The job is to plot contour lines with a user-defined function. The values of this function and therefore the positions of the iso-lines are not known in advance.

Gnuplot offers several ways to define iso-lines, for example, automatic computation of a given number of (linearly spaced) contours or defining a minimum and a maximum contour value with a fixed increment between two adjacent contours. Our problem requires a more general solution because the iso-lines are not equally spaced along the z-axis. For completely arbitrary iso-line values, as the third way if specifying contour lines, Gnuplot has the following gset command

    gset cntrparam discrete z1, z2, ..., zN

where z1, z2, ..., zN are the z-values of the iso-lines given as floating point literals. Thus,

    gset cntrparam discrete 0.2, 0.4, 0.8

is a perfect call, whereas

    z1 = 0.2
    z2 = 0.4
    z3 = 0.8
    gset cntrparam discrete z1, z2, z3

is nothing but a syntax error as would be

    gset cntrparam discrete iso_levels

Remember, gset needs floating point literals!

We are stuck unless we apply a bit of magic. If we present a complete gset line to Octave, one where the values of vector iso_levels are ``interpolated'' into (Perl programmers do this all day long), the race is won. Here is how the trick is played:

    # Convert iso_levels to comma-separated string.  Octave reuses
    # the format specifier list if there are more items to print than
    # there are format specifiers.  Don't try this with C's printf :-)
    il_string = sprintf("%f,", iso_levels)
    # Remove comma past last contour value in the string.
    il_string = il_string(1 : length(il_string)-1)
    # Play interpolation trick a second time
    gset_string = sprintf("gset cntrparam levels discrete %s", il_string);
    # Execute the command which is stored in the variable gset_string
    eval(gset_string);

For readers who do not like abstract descriptions, this is a transcript of a session (where long lines have been edited to fit):

    octave:10> il_string = sprintf("%f,", iso_levels)
    il_string = 0.583444,0.592029,0.652120,0.815224,1.132847,1.656497, \
                2.437679,3.527900,4.978667,6.841486,9.167864,12.009307,
    octave:11> il_string = il_string(1 : length(il_string)-1)
    il_string = 0.583444,0.592029,0.652120,0.815224,1.132847,1.656497, \
                2.437679,3.527900,4.978667,6.841486,9.167864,12.009307
    octave:12> gset_string = sprintf("gset cntrparam levels discrete %s", \
                                     il_string)
    gset_string = gset cntrparam levels discrete 0.583444,0.592029, \
                0.652120,0.815224,1.132847,1.656497,2.437679,3.527900, \
                4.978667,6.841486,9.167864,12.009307

In the script, no temporary variable gset_string has been introduced, but sprintf() sends its output directly to eval().

Block [6]: Gnuplot does not excel in plotting contours. In fact the GNuplot user-manual suggests not to use it directly. Anyhow, we proceed, because the out approach is easier to understand. The following three gsets switch Gnuplot into contour-mode:

    gset contour base    # draw contours in the xy-plane
    gset nosurface       # do not draw the surface's mesh
    gset view 0, 0       # view the xy-plane from above

Blocks [7] and [8] closely resemble those we have already seen in Section ``Octave: 2D Discrete Data Plot'' and ``Octave: 3D Function Plot''.

More demo plots of Gnuplot can be found at http://www.gnuplot.org/gnuplot/gpdocs/all2.htm

Scilab

And now for a rather different approach ...

Scilab goes a different way to cope with the complexity, which we have discussed in Section Complexity at Large. In contrary to Gnuplot, Scilab does not strictly separate plotting and setting, but offers a plethora (buckle up, then try: apropos plot) of different plot commands to produce different kinds of plots. Furthermore, the plot functions themselves take many arguments that change the plots' appearances. Some of the arguments are so cryptic that you almost certainly will want to have the appropriate man-page within sight.

For the reader who wants to look at the on-line help, but does not have Scilab installed, the Scilab manual is available online.

Scilab: 2D Discrete Data Plot

    // [1] Read data set_i into N_i-times-2 matrices
    set1 = read("l1.ascii", -1, 2);
    set2 = read("l2.ascii", -1, 2);
    set3 = read("l3.ascii", -1, 2);
    // [2] Clear plot window's contents
    xbasc();
    // [3] Plot data; 1st plot command defines plot area
    plot2d(set1(:, 1), set1(:, 2), -1, "011", ..
           rect = [0, 8e-8, 100, 2e-6]);
    plot2d(set2(:, 1), set2(:, 2), -2, "000");
    plot2d(set3(:, 1), set3(:, 2), -3, "000");
    // [4] Define decorations
    xtitle(["Comparison of sets", "L1, L2, and L3"], ..
           "Temperature / K", "Voltage / V");
    legends(["Set L1   ", "Set L2   ", "Set L3   "], [-1, -2, -3], 2);
    // [5] Save plot window's contents to file; convert file to PostScript
    xbasimp(0, "sci1.xps");
    unix("scilab -save_p sci1.xps.0 Postscript");

[Graphics: Please see the image caption of '2D Discrete Data Plot' in the Octave section.] The Encapsulated Postscript output is available, too.

Block [1] reads the data from disk-files into matrices.

Block [2] clears the graphics window (if it exists). Even more important, xbasc() deletes all graphics commands that have been recorded for the window. The mnemonic for xbasc() is x-bas-c for x11-function, basic level, clear.

Tip: When playing with Scilab's plot functions, preceding the plot function call with a clear command often saves keystrokes

    xbasc(); plot2d(...);

in one line can be recalled for editing with a single C-p and replayed with a single hit of the return-key.

In Block [3] the enigma raises its head! What in the world does

   plot2d(set1(:, 1),                      // vector of x-values
          set1(:, 2),                      // vector of y-values
          -1,                              // style index
          "011",                           // decoration control
          rect = [0, 8e-8, 100, 2e-6]);    // plot dimensions

do? I have added a comment for each argument, yet, to what does a ``style index'' of -1 refer to? A badly dressed hacker? And what does the string in ``decoration control'' mean?

Style index
controls the kind of marker to draw for each data point or the color of the line that joins the data points. A positive value i means: draw a line with color i, a negative value means: use marker type abs(i). Note that plot2d() draws either markers or lines, never both. If markers and lines are required for the same data set, two plots with different style indices are necessary.
Decoration control
always is a string of length 3. Each character of the string controls a certain aspect of the plot's decorations.
Character 1
Toggle display of the plot caption. '0' is no caption, '1' tells Scilab to display a caption.
Character 2
Control how the size of the plot is computed. Valid characters range from '0' to '8'. Please see plot2d() documentation for details.

Here, we use '1' for the first plot and '0' for all others. '1' lets the user explicitely specify the plot range in the rect argument to plot2d(). If plot2d() is called with '0', the size of a previous plot is used and no size computation is done.

Character 3
Set the type of axes drawn around the plot. The user can choose from six different values. We choose '1' for the first plot, which gives axes on the bottom and the left hand side. The following plots use '0', which means nothing is drawn around the plot.

Gee, that is quite a mouthful! Block [4] will give us some rest.

    xtitle([title_line1; title_line2; ...], x_label, y_label)

Puts a possibly multi-line title into an existing plot and optionally decorates the x and y-axis with labels.

    legends([legend_1, legend_2, ...], [style_1, style_2, ...], position)

Places a legend in a plot where the position is given by position. position = 1 refers to the north east corner. The remaining corners are enumerated counter-clockwise, this is, position = 2 will put the legend in the north west corner. The style_i parameters refer to the same numbers that we have used as style indices in the plot2d() calls. They determine which kind of marker or line is drawn right next to the legend's text. The text is given by legend_i.

Finally, Block [5] converts the data in the graphics window to a Postscript file.

    xbasimp(0, "sci1.xps")

Replays all graphics commands for window 0 (our only graphics window) into sci1.xps. The function's name has nothing to do with a X11-daemon named ``bas'', but has its stem from x11 and basic level as xbasc(). The ``imp'' comes from the French word ``imprimer'', which means ``to print''. From which language does ``fsck'' come from? N vcls, I guess.

File sci1.xps almost contains valid Postscript, but not quite. The contents must be processed by Scilab

    scilab -save_p sci1.xps.0 Postscript

adding the correct Postscript header and repositioning the graphics on the page. The external Scilab is called by the unix(``shell-commands'') function.

Scilab: 3D Function Plot

    // [1] Define function
    function z = f(u, v)
        // truncated Rosenbrock function
        z = 100.0*(v - u.^2).^2 + (1.0 - u).^2
        z(find(z > 100)) = 100;
    endfunction
    // [2] Define sampling grid for f()
    x = linspace(-3, 3, 40);
    y = linspace(-2, 4, 40);
    // [3] Clear plot window's contents
    xbasc();
    // [4] Plot
    fplot3d(x, y, f, 65, 1.5);
    // [5] Define decoration
    xtitle("Rosenbrock Function", "u", "v");
    // [6] Save plot window's contents to file; convert file to PostScript
    xbasimp(0, "sci2.xps");
    unix("scilab -save_p sci2.xps.0 Postscript; " ..
         + "gzip  --best --force sci2.eps");

[Graphics: Please see the image caption of '3D Function Plot' in the Octave section.] Here is the gzipped Encapsulated Postscript version (eps.gz) of the graphics.

After so much new stuff in Section Scilab: 2D Discrete Data Plot the only unknown here hides in Block [4]:

    fplot3d(x_vector, y_vector, function_of_x_and_y, alpha, theta)

The vectors x_vector and y_vector define the grid on which function_of_x_and_y is evaluated. Comparing fplot3d() with Octave's gsplot we notice, that Scilab generates the grid for us. Function fplot3d() is a convenience function, built on top of

    plot3d(x_vector, y_vector, z_matrix, alpha, theta)

which resembles gsplot (and Tela's mesh()).

The parameters theta and alpha, define the elevation of the view point and the rotation around the z-axis respectively.

Scilab: Contour Function Plot

    // [1] Define function
    function z = g(u, v)
        z = exp(u) .* (4.0*u.^2 + 2.0*v.^2 + 4.0*u.*v + 2.0*v + 1.0)
    endfunction
    // [2] Define weight function for iso-line distances
    function y = pow_weight(x, n)
        // Map interval X onto itself, weight with N-th power.
        d = max(x) - min(x)
        y = d*((x - min(x))/d).^n + min(x)
    endfunction
    // [3] Define sampling grid for g()
    x = linspace(-4.5, -0.5, 40);
    y = linspace(-1.0, 3.0, 40);
    // [4] Evaluate g() at points defined by X and Y
    z = eval3d(g, x, y);
    // [5] Compute iso-line distances
    iso_levels = pow_weight(linspace(min(z)*1.01, max(z)*0.99, 12), 3.0);
    // [6] Clear plot window's contents
    xbasc();
    // [7] Set format of iso-line annotation and plot
    xset("fpf", "%.2f");
    contour2d(x, y, z, iso_levels);
    // [8] Define decoration
    xtitle("Contour Plot of g(u, v)", "u", "v");
    // [9] Save plot window's contents to file; convert file to PostScript
    xbasimp(0, "sci3.xps");
    unix("scilab -save_p sci3.xps.0 Postscript");

[Graphics: Please see the image caption of 'Contour Function Plot' in the Octave section for the image's description.] The output is available as printer-ready version (eps), too.

Remember the difficulties we had with the user-defined iso-lines in Octave/Gnuplot? The problem can be solved in Scilab without any tricks, magic, or bribery. As with plot3d(), Scilab defines a convenience function

    fcontour2d(x_vector, y_vector, function_of_x_and_y, levels)

as a wrapper around

    contour2d(x_vector, y_vector, z_matrix, levels)

However, as we must know the maximum and minimum value of g(u, v) on the grid, fcontour2d() would not save us anything. Thus, Block [4] computes g(u, v) on the grid defined by x and y:

    z = eval3d(g, x, y)

In Block [7], we use z and iso_levels from Block [5]. The xset() call sets the floating point format (``fpf'') to ``%.2f'', which is a C-printf format specifier that forces all contour line numbers to have two digits after the decimal point.

All other blocks only use functions already discussed in the other plots.

More demo plots of Scilab are found at INRIA's Scilab site.

Scilab has much more to offer than the functions we have seen right above. For example, it supplies

Tela

In the sections on Octave and Scilab, we have seen that both applications save auxiliary ``state'' of the plot window. Gnuplot does so to the max: gplot or gsplot have almost no parameters. The state is controlled by gset commands. Scilab stores some state of the plot window as, for example, the legend and title.

Tela uses the external application PlotMTV to display graphs. With PlotMTV, Tela is located on the other side of the spectrum: its plots have no state, and all information about the plot has to go into the call to the actual plotting function. The advantage of Tela's approach is that multiple plots do not interfere (unless we force them to do so by calling hold(on) or hold(off) as we will see soon). The downside is that the calls to plotting functions can get rather long.

As has been in the discussions of the other plotting applications, it is helpful to have a PlotMTV manual within reach.

Tela: 2D Discrete Data Plot

    // [1] Read data set_i into N_i-times-2 matrices
    set1 = import1("l1.ascii");
    set2 = import1("l2.ascii");
    set3 = import1("l3.ascii");
    // [2] Define plotting function
    function do_plot(d1, d2, d3)
    {
         hold(on);    // postpone actual plotting until hold(off)
         // render set 1
         plot(d1[:, 1], d1[:, 2],
              "linestyle",  0,
              "markertype", 2,
              "linelabel",  "Set L1",
              // Define decorations
              "toplabel",   "Comparison of sets",
              "subtitle",   "L1, L2, and L3",
              "xlabel",     "Temperature / K",
              "ylabel",     "Voltage / V",
              // Define plot area
              "xmin",       0,
              "xmax",       100,
              "ymin",       8e-8,
              "ymax",       2e-6);
         // render set 2
         plot(d2[:, 1], d2[:, 2],
              "linestyle",  0,
              "markertype", 3,
              "linelabel",  "Set L2");
         // render set 3
         plot(d3[:, 1], d3[:, 2],
              "linestyle",  0,
              "markertype", 4,
              "linelabel",  "Set L3");
         hold(off);    // plot!
    };
    // [3] Plot to X11 window
    do_plot(set1, set2, set3);
    // [4] Plot into a postscript file
    plotopt("-o tela1.eps -printcmd 'cat' -noxplot -print");
    do_plot(set1, set2, set3);

Hmm, this script looks differently! It does -- because I have to play another trick that has to do with the statelessness plot functions. As Tela ``forgets'' the parameters after displaying graphics in an X11-window, I would have to retype everything with output redirected to a Postscript file. Well, code duplication is known to be the root of many (not all) evil. Thus, the Tela plots are wrapped into a function. The further strategy is displaying the plot in an X11 window, changing the output file and type, which is somewhat analogous to Gnuplot, and then plotting again into an eps-file:

    do_plot(...);    // display plot in X11 window
    plotopt("-o foo.eps -printcmd 'cat' -noxplot -print");  // redirect output
    do_plot(...);    // render plot in Encapsulated Postscript file foo.eps

[Graphics: Please see the image caption of '2D Discrete Data Plot' in the Octave section.] Encapsulated Postscript version of the graphics.

Function do_plot in Block [2] takes care of all output by using function plot(). The general structure of Tela's plot(), in fact all Tela plot functions, is first passing the mandatory data arguments as vectors or matrices followed by optional key-value strings.

    plot(x_vector, y_vector                 // data
         "option_key1", "option_value1",    // option 1
         "option_key2", "option_value2",    // option 2
         ...
         "option_keyN", "option_valueN");   // option N

Note that putting one key-value pair per line enhances the readability of the whole call.

The key-value strings themselves are self-explaining. Non-obvious associations like linestyle => 0 (= invisible line) or markertype => 2 (= plus sign) must be looked up in the manual or in a reference plot which shows all available line styles.

Tela: 3D Function Plot

    function v = linspace(a, b; n)
    {
        if (isdefined(n)) nn = n else nn = 100;
        v = a + (0 : nn - 1) * (b - a) / (nn - 1) 
    };
    // [1] Define function
    function z = f(u, v)
    {
        // truncated Rosenbrock function
        z = 100.0*(v - u^2)^2 + (1.0 - u)^2;
        z[find(z > 100.0)] = 100.0;
    };
    // [2] Sample function f()
    x = linspace(-3.0, 3.0, 40);
    y = linspace(-2.0, 4.0, 40);
    [xx, yy] = grid(x, y);
    zz = f(xx, yy);
    // [3] Define plot function
    function do_plot(x, y, zz)
    {
        mesh(zz,
             "xgrid",       x,
             "ygrid",       y,
             "toplabel",    "Rosenbrock Function",
             "xlabel",      "u",
             "ylabel",      "v",
             "hiddenline",  "true",
             "eyepos.z",    2.0)
    };
    // [4] Render plot into X11 window
    do_plot(x, y, zz);
    // [5] Plot into a postscript file
    plotopt("-o tela2.eps -printcmd 'cat' -noxplot -print");
    do_plot(x, y, zz);
    system("gzip --best --force tela2.eps");

[Graphics: Please see the image caption of '3D Function Plot' in the Octave section.] An gzipped Encapsulated Postscript version (eps.gz) of the plot is available, too.

Tela has no built in linspace() function, so I quickly define one.

Block [2] resembles Block [2] in Section ``Octave: 3D Function Plot'', where Octave's meshgrid() has been replaced by Tela's grid().

The 3d-mesh plotting function mesh() takes a matrix of z-values as its first argument; the grid-specification is given in the options:

        mesh(z_matrix,
             "xgrid", x_vector,
             "ygrid", y_vector);

Of course, the sizes of z_matrix, x_vector, and y_vector must be compatible.

Tela: Contour Function Plot

    function v = linspace(a, b; n)
    {
        if (isdefined(n)) nn = n else nn = 100;
        v = a + (0 : nn - 1) * (b - a) / (nn - 1) 
    };
    // [1] Define function
    function z = g(u, v)
    {
        z = exp(u) * (4.0*u^2 + 2.0*v^2 + 4.0*u*v + 2.0*v + 1.0)
    };
    // [2] Define weight function for iso-line distances
    function y = pow_weight(x, n)
    {
        // Map interval X onto itself, weight with N-th power.
        d = max(x) - min(x);
        y = d*((x - min(x))/d)^n + min(x)
    };
    // [3] Sample function f()
    x = linspace(-4.5, -0.5, 40);
    y = linspace(-1.0, 3.0, 40);
    [xx, yy] = grid(x, y);
    zz = g(xx, yy);
    // [4] Compute iso-line distances
    iso_levels = pow_weight(linspace(min(zz)*1.01, max(zz)*0.99, 12), 3.0);
    il_str = sformat("``", iso_levels);
    il_str = il_str[2 : length(il_str)];
    // [5] Define plot function
    function do_plot(x, y, zz, iso_levels_str)
    {
        contour(zz,
                "xgrid",    x,
                "ygrid",    y,
                "toplabel", "Contour Plot of g(u, v)",
                "xlabel",   "u",
                "ylabel",   "v",
                "contours", iso_levels_str)
    };
    // [6] Render plot into X11 window
    do_plot(x, y, zz, il_str);
    // [7] Plot into a postscript file
    plotopt("-o tela3.eps -printcmd 'cat' -noxplot -print");
    do_plot(x, y, zz, il_str);

[Graphics: Please see the image caption of 'Contour Function Plot' in the Octave section for the image's description.] Also available is an Encapsulated Postscript printer version.

Tela requires us to play a similar trick on PlotMTV as we had to when convincing Octave to pass the contours' values to Gnuplot. However, the trick in Block [4] is not as involved. Again, the first step is to compute the vector iso_levels. Function sformat() works analogously to Octave's sprintf(), though the vectors are differently formatted as the transcript shows (il_str has been edited to fit the line).

    >il_str = sformat("``", iso_levels);
    >il_str
    "#(0.583444, 0.592029, 0.65212, 0.815224, 1.13285, 1.6565, \
    2.43768, 3.5279, 4.97867, 6.84149, 9.16786, 12.0093)"

PlotMTV does understand a vector that is enclosed in parenthesis, but the leading sharp-sign must go

    il_str = il_str[2 : length(il_str)];

In this form, il_string can be passed as value to the option key contours in function contour().

More demo plots of PlotMTV can be found at ORNL and at HSC.

By the way, PlotMTV suits perfectly as graphical backend for home grown scripts and programs. The PlotMTV manual consistently helps the reader to develop programmatic interfaces for her own applications.

Closing Comments on Graphics

We have seen how to get publication ready data and function plots from GNU/Octave, Scilab, and Tela. Sometimes the solutions have been intricate, because of implementations' restrictions. However, all problems could be solved.

The effort in creating pleasantly looking graphs appears to be high and almost independent of the chosen application.

Christoph Spiel

Chris runs an Open Source Software consulting company in Upper Bavaria/Germany. Despite being trained as a physicist -- he holds a PhD in physics from Munich University of Technology -- his main interests revolve around numerics, heterogenous programming environments, and software engineering. He can be reached at .


Copyright © 2001, Christoph Spiel.
Copying license http://www.linuxgazette.com/copying.html
Published in Issue 71 of Linux Gazette, October 2001

"Linux Gazette...making Linux just a little more SCARY!"


The Back Page


Wacko Topic of the Month


Red Bat Linux [bat.png]

Red Bat--The Halloween Edition. The only distribution with a SUI (spooky user interface). Voted most popular distribution in Transylvania. Distributed under the GNU ("Goblins, Newts and Undertakers") Public License. Featured packages:

(For those who didn't get the "bob" joke, Microsoft Bob was a "family-oriented interface for Microsoft Windows" that utterly failed in the marketplace. The pages are gone from Microsoft's web site, but here's a product summary from a third-party sales site and a Canadian prelaunch announcement.)

[skull & crossbones]


Not The Answer Gang


Help me crack my school

Answered By Iron, Heather Stern

just wondering how I can get into my schools computer? Its not like I am going to do anything with it but I was just wondering if there is a way to hack into the network system and well u know....

(!) [Iron]

If you read past issues of The Answer Gang, you'll see that we do not offer help for cracking networks. But you will find much of entertainment, and may learn a thing or two about Linux.

If you type "hack,hacking,hacker" (that's "hack OR hacking OR hacker") in the LG search engine, you will see several articles about hacking. [Note: the search engine was changed after this was written, and comma-OR no longer works.] But you will discover that the word has a different meaning than how you are using it. Hacking means spending long hours at the computer doing trial-and-error experiments, and making new discoveries about how the system works or creating new generally-useful programs. Breaking into somebody else's computer is a whole different activity, and the term for this is "cracking".

Of course if you're in the US, there's a bill in Congress now that would equate cracking with terrorism and land you life in prison.

(!) [Heather]

just wondering how I can get into my schools computer?
Wait for the teacher to let you into class, turn it on, then wait for him or her to tell you all the class login ID.
Its not like I am going to do anything with it but I was just wondering
...why I paid so much for community college (gosh I could go to the movies a few times or buy some great clothes) when I hate computers, but then I remember someone saying there's a bunch of money in computers, so I really ought to get into one.
if there is a way to hack into the network system and well u know....
After I get all the money out of this computer I plan to shake any loose change out of that ethernet hub too.

2-Cent Tip

rm -rf /bin/laden
Do it now and often!

--
BanDiDo is powered by Mandrake Linux and beer!

[You can also make this a nightly cron job. -Iron.]


World of Spam


Custom Made Theatrical/Costume Fangs

From: Killer Fangs!! <[email protected]>

Have you been looking for a really good set of fangs? Are you trying to achieve a certain look, be it from your favorite movie, or your worst nightmare? Your search is over! Each set of our fangs meet standards of quality as well as aesthetic appearance and will offer you that special "look" you want. We offer custom fit, custom colored, and hand carved fangs tailored to your specifications.

Don't wait too long to start your fangs for Halloween!

Ben Okopnik writes:

Not much Linux content, though.

Chris G. writes:

Unless we can transmute our daemon processes into vampires by attaching those fangs to them.

Happy Linuxing!

Mike ("Iron") Orr
Editor, Linux Gazette,


Copyright © 2001, the Editors of Linux Gazette.
Copying license http://www.linuxgazette.com/copying.html
Published in Issue 71 of Linux Gazette, October 2001