My position is that if the actual terms under which the software is
distributed are OK, the author is free to ask people to voluntarily do
anything, including send them money.
The terms of the Chat software look a lot like the usual Berkeley, GNU,
utzoo, or other terms: keep our copyright, include the whole piece of
work, let people know it can be gotten for free if you charge for it, etc.
In fact the legal terms are less restrictive than the GNU software;
GNU won't let you redistribute in binary without source, and the only mod
you can make to the terms is to add a warrantee.
Carl Gutekunst's entry in the "comp.sources.unix archives" listing says
that to get tapes of archived software from him, you should "call WELL in
advance and bring lunch money". Is that an outrageous thing to ask?
How does that compare with asking people who use the software to
voluntarily send in $29? I think both are fine as long as people who
disagree are able to legally get and use the software for no money.
If you like this article and you want to reward me, just email your
contribution, in US$, to g...@toad.com :-).
--
{pyramid,ptsfa,amdahl,sun,ihnp4}!hoptoad!gnu g...@toad.com
"Watch me change my world..." -- Liquid Theatre
It's worth remembering, long and often, that the person who pretty much
invented the 'Shareware' concept, the late Andrew Fluegelman, called
it 'Freeware' and repeatedly emphasized the fact that the person who
used his software was under no, repeat, NO, obligation to send any
money unless they felt like it. They were free to use it, copy it, give
it away, anything they liked, all without paying a dime. If, however,
they used it and liked it, they were encouraged (NOT required) to contribute
money - the amount was suggested, but NOT legislated. They could send
less, or more, as their conscience required.
Andrew's concept has always struck me as being eminently fair and
enlightened. I only wish that all the other 'shareware enterpreneurs'
had taken his lead. Instead, they try and demand payment, which
demeans both themselves and their customers. It's worth noting,
also, that Andy Fluegelman made out like a bandit - he found that when
given the chance, and not pressured, people responded. Funny thing,
that - when trust is given, trust is repaid. What a revolutionary
concept!
--
Michael J. Farren | "INVESTIGATE your point of view, don't just
{ucbvax, uunet, hoptoad}! | dogmatize it! Reflect on it and re-evaluate
unisoft!gethen!farren | it. You may want to change your mind someday."
gethen!far...@lll-winken.arpa | Tom Reingold, from alt.flame
> My position is that if the actual terms under which the software is
> distributed are OK, the author is free to ask people to voluntarily do
> anything, including send them money.
I'd just like to say I support your position absolutely!
> If you like this article and you want to reward me, just email your
> contribution, in US$, to g...@toad.com :-).
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
(Is that enough $? If not I'll post some more ... hey, no problem!)
(Mailer food)
--
William Phillips {allegra,philabs,cmcl2}!phri\
Big Electric Cat Public Unix {bellcore,cmcl2}!cucard!dasys1!wfp
New York, NY, USA (-: Just say "NO" to OS/2! :-)
Wouldn't you rather have a hard currency.
The US$ is a bit soft these days. :->
michael
--
Michael Felt Psychology Dept, Vrije Universiteit, Amsterdam, Netherlands
InterNet: mic...@psy.vu.nl
UUCP: ...!mcvax!vupsy!michael , mic...@vupsy.UUCP
AppleLink: HOL0038
Question: What motivates a programmer to develop a large complex software
system, perhaps requiring many weeks (or even years) of development effort,
which is then posted for the world to use, for free?
--
Dominick Samperi, Manhattan College, New York, NY
...!ihnp4!cmcl2!manhat!samperi
...!ihnp4!cmcl2!phri!dasys1!samperi
Lest anyone get the wrong impression :-), that statement is intended to be
toungue-in-cheek. I like meeting new people, and if someone is making the
effort to drop by my office with a mag tape, then the least they can do is
stick around for lunch.... No, I don't expect them to buy mine! :-)
<csg>
I agree. The moniker "Freeware" is usually associated with the granddaddy
of such program offerings, PC-Talk. I'm curious if Fluegelman's concept
really was as profitable as all that given that (the last I heard) PC-Talk
dumped Freeware and went commercial.
>Question: What motivates a programmer to develop a large complex software
>system, perhaps requiring many weeks (or even years) of development effort,
>which is then posted for the world to use, for free?
What motivates me is lack of resources to even consider marketing Magpie
commercially. Five years ago, you could stick a floppy disk and a few
sheets of offset-printed literature in a baggy and call it a commercial
program. That was back when, except for a few heavy guns, most
software was sold with about the same level of sophistication as your
neighborhood dope dealer. I'll be releasing Magpie Shareware very soon
(maybe January) but without any tricky internal counters or lockouts. I
don't plan on making bus fare from it. However, enhancements are already
planned and those will go into a commercial version. By then, I hope
there's enough name recognition and appreciation for the program that
people will "upgrade" for the sake of a more heavily-featured version. If
not, no reprisals (the unconscionable swine).
--
+-----------------------------------------------------------------------
+ Steve Manes Roxy Recorders, Inc. NYC
+ decvax!philabs!cmcl2!hombre!magpie!manes Magpie BBS: 212-420-0527
+ uunet!iuvax!bsu-cs!zoo-hq!magpie!manes 300/1200/2400
Perhaps the "original developer" of the shareware/freeware concept
wasn't interested in making a killing in terms of money. Maybe s/he
wanted to let everyone have a useful hack but wanted a little return
on his or her time and effort. Maybe people who used it were
impressed by the generosity and trusting attitude of said person
compared to the more predatory ("We don't warranty that this will even
load in off disk, but if you so much as let anyone else use this,
we'll come in and take everything you own") software houses and
decided that a good deed merits a good deed in response.
]Question: What motivates a programmer to develop a large complex software
]system, perhaps requiring many weeks (or even years) of development effort,
]which is then posted for the world to use, for free?
Perhaps a desire to help others?
There's actually another reason why some people may distribute
software in a shareware fashion. Suppose you sell something for $300,
but 9 out of 10 copies out there are "shared", "pirated", or whatever.
Now, most of those may be done one at a time, rather than by really
organized pirates. Suppose that instead you distribute it shareware,
and 80% of the people with copies send you $50. You're coming out
better in the long run and it's much less effort (your sales budget is
much lower, etc.). You'll never be able to go after the people
copying your program in the first case, but you're losing a lot per
copy.
harvard >>>>>> |
bloom-beacon > |think!rlk Robert Krawitz <r...@think.com>
ihnp4 >>>>>>>> .
Perhaps. I tend to believe that it could work, even now, but have no
way of proving this (short of doing it and making a killing, of course :-)
>Question: What motivates a programmer to develop a large complex software
>system, perhaps requiring many weeks (or even years) of development effort,
>which is then posted for the world to use, for free?
Because of philisophical disagreement with the way our economic system
operates.
Because of a desire to see one's name spread as far and wide as possible.
Because of a lack of funding to support a 'commercial' release.
Because of a desire to avoid the compromises and interference that a
marketing department might force.
Because of a desire to see something one thinks of as useful and neat
available to as many others as possible.
These are examples. I'm sure you can think of others. There seem to
be as many reasons for shareware distribution as there are people
doing it.
I wrote Freemacs (the only freely copyable programmable editor for the IBM
PC and clones) because FSF's GNU emacs is too big to run on PCs. I
did it for my own use, but I would rather see large numbers of people
gain from my effort, so I distribute it for free. Because of the nature
of the program, mostly techies are attracted to it, so I don't get many
calls of the form "Which way do I put the floppy into the drive?" questions.
My reward is the satisfaction of a job well done.
-russ
> Question: What motivates a programmer to develop a large complex software
> system, perhaps requiring many weeks (or even years) of development effort,
> which is then posted for the world to use, for free?
About five years ago I developed a database system and report writer. It
runs under just about any Unix, uses curses, and so on. Back then it was
fairly state of the art for Unix on PC's. Then, RDS came out with Informix
and blew my dreams of selling this thing and making a fortune.
At one time the sources were available to friends and so on. Now, I'm
writing a new database system to replace Informix 3.30, and I need to keep
my grubby hands on the code. If you knew me 4 or 5 years ago, you'd have
gotten a nice, fast, little database system for free.
That project took 6000+ hours of programming and in original form was
15,000 lines of assembler. But, given that it had no commercial value,
well, why not give it away? Or maybe charge for the documentation.
[ Informix is a trademark of Relational Database Systems, or whatever they
changed their name to. ]
> --
> Dominick Samperi, Manhattan College, New York, NY
- John.
PS - I may be releasing an ACE parser and listing generater to the net
sometime soon. I can't see that having much real commercial value either.
I guess that's the key to what it takes me to release (free|share)ware.
--
John F. Haugh II (jfh@killer) | "There are really not many jobs that actually
HECI Exploration Co. Inc. | require a penis or a vagina, and all other
11910 Greenville Ave, Suite 600 | occupations should be open to everyone."
Dallas, TX. 75243 | - Gloria Steinem
"Shareware, as used in this document, is a marketing technique for commercial
software packages in which the software may be freely copied and shared,
but voluntary payment (registration) is expected from people using the
software. The term "shareware" is a generic term for this technique,
coined by myself. The phrase "user supported software", used by
Buttonware, is (as far as I know) equivalent. The word "Freeware" is a
trademark of The Headlands Press (unless they decide to release it) and
so should not be used. "Public domain software" means non-copyrighted
software; that is, software anyone can modify, rename, sell, give away,
etc.
The main reasons for using this shareware approach are:
1. Providing useful software to as many people as possible.
2. Providing more value to customers by providing a way to evaluate
the software at little risk.
3. Developing a large user base who may want to purchase additional
goods and services.
4. Developing a high market share for a particular category of
software.
5. Communicating the benefits of the software in an effective way,
using the actual software.
6. Communicating the benefits of the software in an inexpensive way,
compared to advertising.
...
Shareware is successful for a software package if:
The number of people who BUY it BECAUSE it is shareware
outnumber those who DO NOT BUY it BECAUSE it is shareware.
The number who do buy it because it is shareware are those who:
1. Are aware of and/or try the package ONLY because it is shareware, and
2. Who then register after trying it.
Those who take step one but not step two do not affect the analysis.
The number who do not buy it because it is shareware are those who:
1. Are aware of and/or try the package ONLY because it is shareware, and
2. Who then use the package without registering it, and
3. Who WOULD have bought the package, had it not been shareware.
Those who take steps one and two but would not have bought anyway
(pirates) do not affect the analysis.
...
Why Shareware Works -- summary
Many people try PC-Write, like it, and register their copy with us.
People register for many reasons. Some want the printed manual, phone
support, or other services. Some feel it is the moral or honorable
thing to do. Some want to belong, to feel appreciated (and they are!) or
want to support us. Shareware only works for software people find
valuable. It works best for software people use every day. It works
best for a small software company, since each person's registration
makes a difference.
Software packages are alive, in some sense. They evolve: bugs get
fixed, new features get added, they get adapted to new environments,
like new computers or operating systems. People use packages in new
ways, and discover new behavior patterns. But a package is only alive
if someone supports it. Most people prefer living software. Most
invest some effort learning their software. So, most will pay a
reasonable amount to keep their software alive.
Diskettes are easy to copy. People can make perfect copies quickly
using normal equipment. Compare this with print, audio, or video media!
People like to share useful things with others, if the cost and risk to
them is low. And people often choose things based on word of mouth.
Shareware is just "word of disk". It both promotes and distributes our
product. People can try our software without risking a lot of money (or
breaking the law). Computes are risky enough. People trying our
product can relax; if they don't like it, it's no loss. People
appreciate that."
End of quote. There's a lot more, but this was the part most relevant
to the Usenet discussion.
--
{pyramid,ptsfa,amdahl,sun,ihnp4}!hoptoad!gnu g...@toad.com
I forsee a day when there are two kinds of C compilers: standard ones and
useful ones ... just like Pascal and Fortran. Are we making progress yet?
-- ASC:GUTHERY%slb-test.csnet
I am getting ready to release a product called HDSCAN to
comp.sources.misc as shareware. This is a product that I have out for
the Atari ST which I ported over to my Symmetrics (BSD) box out of
simple necessity. Basically, HDSCAN is a directory tree peruser,
with some of the best features of programs like XTREE, 1DIR, SWEEP,
and other PC programs. I treat it as a tool for cleaning up
directories, re-organizing my hard disk, performing incremental
backups, performing operations on groups of files scattered across
partitions, etc.
Actually, there is one other nice feature of shareware that I have
found pleasing on the Atari ST...you get lots of nice letters from
people thanking you for the program. Positive feedback is probably the
best reward to shareware. I do have to agree with a previous poster,
however, in that the days of making a living from a shareware program
are pretty much gone.
Oh yes...hdscan will also run on SysVr2 and SysVr3.
-Todd Burkey
t...@stag.UUCP
(Why do I do crossword puzzles?)
In article <14...@think.UUCP> r...@think.COM (Robert Krawitz) writes:
>Perhaps a desire to help others?
Or for my own reasons: the challenge of solving a puzzle; the desire
to be famous; and probably most important, a neurotic need to prove
myself :-) .
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain: ch...@mimsy.umd.edu Path: uunet!mimsy!chris
So send the guy ten or fifteen dollars, with a note explaining that you
only thought it was worth that much, and why. He'll be grateful (believe
me!) for the money, or ANY money for that matter, and just might try and
make improvements based on your suggestion. If the $35 was to register
the software, and get fancy manuals, you might not get them, but you
will have registered your opinion in the best way I can think of - by way
of the pocketbook.
Most of the shareware I've seen has the line "Suggested Donation" in
there somewhere. I take this to mean that I'm not required to give
them that much if I don't think the package was worth it.
--
Michael J. Farren | "INVESTIGATE your point of view, don't just
{ucbvax, uunet, hoptoad}! | dogmatize it! Reflect on it and re-evaluate
unisoft!gethen!farren | it. You may want to change your mind someday."
gethen!far...@lll-winken.llnl.gov ----- Tom Reingold, from alt.flame
I gross an average of $5.00 a day from my shareware, and for each check
I receive I mail the user a disk with the current versions of the
shareware. My costs for materials, labor, and post box rental mean
that my profit is quite small, not to mention the inconvenience to me
in the form of early morning phone calls, from customers who want to
praise me, or get my help.
Unfortunately, I picked a price too low to include the cost of selling, so
no retailer can afford to carry it. The price is also too low to include
the cost of an employee, so I must do all the work myself.
I used to offer complete source, on request, on condition that all changes
be reported back to me for incorporation into the "official" version.
Since not a single person returned any changes to me, I don't offer source
anymore. My reputation rests on the quality of my work. Inferior
imitations based on my work make me furious, particularly if they confuse
ordinary people, making them believe I did a shoddy job.
I have also written a few clever hacks, which are pretty to look at, but
not strictly _useful_ to anybody. Since I believe in value for money, I
don't ask for anything for these.
Why do I do it?
0.) It has much less stigma in the Macintosh end of the net. People there
seem to feel that an author asking for money is just part of his freedom
of speech.
1.) I have expenses. I am not rich. I can't afford to give my work away.
2.) I wanted to learn about running a small business without going many
tens of thousands of dollars into debt raising working capital.
3.) if you hire a publisher to publish your work (obviously publishers
have a different perspective on this relationship: they think they are
hiring you.) You'll pay about $0.80 out of every dollar your software
makes the publisher for the priviledge. The publisher's expenses in turn
mean that there is a lot of good, small software, that no-one can afford
to conventionally publish.
but mostly:
4.) a check in the mail is a _very_ sincere form of fan mail. I'm glad
that people like my stuff enough to pay for it, and I like to hear what
they'd like to see in the future. (It is particularly a kick to get a fan
letter from someone I respect.)
If you don't like my stuff, if you don't like me, or if you don't like my
requesting money, you won't pay me. But, I like living in a world where
people send me fan mail with money in it.
My most recent posting is public domain: it animates a ball bouncing
around an endlessly rising staircase, with accompanying endlessly rising
music. It requires the host computer have a 4 voice sound system (the
Macinotosh does.) I know they taught us in class that all computers are
Turing-equivalent, but I have yet to see a Turing machine with a 4 voice
sound system.
--- David Phillip Oster --A Sun 3/60 makes a poor Macintosh II.
Arpa: os...@dewey.soe.berkeley.edu --A Macintosh II makes a poor Sun 3/60.
Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu
Answer 3: The programmer wrote the program for some specific purpose; after
the program has fulfilled that purpose, the programmer decides to see if
anyone else might be able to use it. Since the program has already "paid for
itself", the programmer sees no reason to charge for it. This motivates many
of my (personal) sources postings.
--
Brandon S. Allbery, Moderator of comp.sources.misc
{hoptoad,harvard!necntc,cbosgd,sun!mandrill!hal,uunet!hnsurg3}!ncoast!allbery
[This space reserved for future quotes and similar brain twisters.]
One way to get an extended answer to this question is to read "The GNU
Manifesto" written by RMS.
A short, partial answer is that one can learn the most, and
debug/enhance a program the fastest by trying to provide it (ie., the
source) to the widest possible audience.
--woodstock
--
"How did you get your mind to tilt like your hat?"
...!{decwrl|hplabs!oliveb|pur-ee|qantel|amd}!intelca!mipos3!cpocd2!nate
<domainish> : na...@cpocd2.intel.com ATT : (602) 961-2037
Dominick, if you have to ask you will never understand :-)
I, for one, get great joy out of producing a good piece of software and
having many other people use it. In a way, it is grabbing a small
handful of fame in a group of people you respect and who, after running
your program, probably respect you; plus, if someone sees a better way
of doing something, you may get the joy of watching your program grow
(or shrink), get better, faster, have features added, and so on. Or, a
subroutine may be particularly well done, and you may see it crop up in
other people's code -- always a nice surprise.
Shareware is a little trickier than Freeware in this case; people are
less likely to lift code, and are less likely to admit so when they
do. On the other hand, it can mean pocket change; and, after all,
money is a universal symbol in our culture for appreciation of value
received.
Greg Limes
ARPA: li...@sun.com UUCP: ..!ucbvax!sun!limes
Disclaimer: I do not speak for Sun Microsystems, they hire
other people to do that.
Forgive me if this has been stated before, the large volume of net-noise 8-)
makes it hard to read all articles.
A real good reason I can think of to develop Shareware is that since the author
can Copyright the code, pre-release versions can be circulated as a sort of
alpha test. This will do a couple of things:
1. Give good code to those too cheap to support you 8-)
2. Expose your product (and thus make your program well known.)
3. Allow the multitudes to point out subtle bugs and suggest some
improvements you had not thought of or overlooked.
4. Give you some money to buy new blank development disks 8-)
Besides, it follows the hacker spirit!
==============================================================================
Jim Sewell "Make knowledge free!"
I suppose I can use myself for an example.
All of the reasons mentioned above play a part, but I feel like they all miss
the point slightly.
At the start of any project, I'm programming primarily to please myself. (The
two chief virtues in a programmer are laziness and impatience.) After a while
somebody looks over my shoulder and says, "That's neat. It'd be neater if it
did such-and-so." So the thing gets neater. Pretty soon (a year or two) I
have an rn, a warp, a patch, or a perl. One of these years I'll have a
metaconfig.
I then say to myself, "I don't want my life's work to die when this computer
is scrapped, so I should let some other people use this. If I ask my
company to sell this, it'll never see the light of day, and nobody would pay
much for it anyway. If I sell it myself, I'll be in trouble with my company,
to whom I signed my life away when I was hired. If I give it away, I can
pretend it was worthless in the first place, so my company won't care.
In any event, it's easier to ask forgiveness than permission."
So a freely distributable program is born.
At this point I'm no longer working for a company that makes me sign my life
away, but by now I'm in the habit. Besides, I still harbor the deep-down
suspicion that nobody would pay money for what I write, since most of it
just helps you do something better that you could already do some other way.
How much money would you personally pay to upgrade from readnews to rn?
How much money would you pay for the patch program? As for warp, it's a mere
game. And anything you can do with perl you can eventually do with an amazing
and totally unreadable conglomeration of awk, sed, sh and C.
It's not so much that people don't value the programs after they have them--they
do value them. But they're not the sort of thing that would ever catch on
if they had to overcome the marketing barrier. (I don't yet know if perl will
catch on at all--I'm worried enough about it that I specifically included an
awk-to-perl translator just to help it catch on.) Maybe it's all just an
inferiority complex. Or maybe I don't like to be mercenary.
So I guess I'd say that the reason some software comes free is that the
mechanism for selling it is missing, either from the work environment, or
from the heart of the programmer.
What programmers like me need is a benefactor, like the old composers and
artists used to have. Anybody want to support me while I make beautiful things?
My hope is that some billionaire who reads the net for pleasure(?) will
someday say "I'd like to pay you for all the people who have used rn over
the years..." and drop $1,000,000 or so on me so I could live off the interest
and finish the new rn. :-)
If you are a benefactor, my address is 9132 Kester Ave, Panorama City, CA 91402,
and my phone number is (818) 893-8182. only 1/2 :-)
If you aren't a benefactor, that's ok, I really expect my rewards in heaven.
Larry Wall
lw...@jpl-devvax.jpl.nasa.gov
> How much money would you personally pay to upgrade from readnews to rn?
Given how much time it saves me, $50-$100 seems appropriate.
> How much money would you pay for the patch program?
At this point it's such a standard tool that it's absolutely necessary.
Try working on X-windows without patch, for example. Again, I'd certainly
pay $50 for it. People like Locus Computing, who have to have it, should
be willng to pay $250 (though I don't know if they are).
> It's not so much that people don't value the programs after they have them--they
> do value them. But they're not the sort of thing that would ever catch on
> if they had to overcome the marketing barrier.
Despite what I said above, this is true. I doubt I'd pay for rn if I didn't
already have it. (Patch, though, is another story.)
(Sorry, Larry, I know it was a rhetorical question. But I just *had*
to answer.)
--
Geoff Kuenning ge...@ITcorp.com {uunet,trwrb}!desint!geoff
-- bd
Oops. Forgot to say.
First, where you can get it: perl has been in the queue of comp.sources.unix
since mid-December, and should come out within a week or so of whenever that
newgroup starts up again. Until then you can snarf it via anonymous ftp from
my site, jpl-devvax.jpl.nasa.gov (128.149.8.43).
As to what it is, here's the hype paragraph from the manual page:
Perl is a interpreted language optimized for scanning arbi-
trary text files, extracting information from those text
files, and printing reports based on that information. It's
also a good language for many system management tasks. The
language is intended to be practical (easy to use, effi-
cient, complete) rather than beautiful (tiny, elegant,
minimal). It combines (in the author's opinion, anyway)
some of the best features of C, sed, awk, and sh, so people
familiar with those languages should have little difficulty
with it. (Language historians will also note some vestiges
of csh, Pascal, and even BASIC-PLUS.) Expression syntax
corresponds quite closely to C expression syntax. If you
have a problem that would ordinarily use sed or awk or sh,
but it exceeds their capabilities or must run a little fas-
ter, and you don't want to write the silly thing in C, then
perl may be for you. There are also translators to turn
your sed and awk scripts into perl scripts.
That's all I wanted to put in the manual page, but I could tell you a little
more. First of all, why I wrote it: I wanted to set up a distributed
configuration control system based on the news system, and I had to be
able to print reports based on scanning a bunch of articles. Awk and sed
didn't permit me to navigate around the news system like I wanted to do
(following embedded references to other articles). The shells can navigate,
but you can't do anything efficiently when you have to start up a new
process every time you turn around. I could have done it in C, of course,
but text processing in C is an ungainly proposition at best. On top of which,
C didn't have the picture-style report formats I wanted. And I didn't want
to do a make every time I tweaked the program.
Somewhat later I realized that many systems programming problems deal with
text--the situation arises frequently that you want to take the output of
various status programs (either directly via a pipe or indirectly from a log
file) and massage the data to show you just what you want to know, or pick
out various bits of information to drive some other operation. In the first
category is a set of LAN-wide status reporting scripts that deliver a report
to me each morning concerning anomalous conditions on any of the machines I'm
responsible for. In the second category are programs like gsh and gcp, which
are just like rsh and rcp except that they work globally on some set of machines
defined in a system file. In fact, I'll show you some of those programs to
give you a taste of perl:
Here's gsh:
--------------------------------------------------------------------------------
#!/bin/perl
$SIG{'QUIT'} = 'quit'; # install signal handler for SIGQUIT
while ($ARGV[0] =~ /^-/) { # parse switches
$ARGV[0] =~ /^-h/ && ($showhost++,$silent++,shift,next);
$ARGV[0] =~ /^-s/ && ($silent++,shift,next);
$ARGV[0] =~ /^-d/ && ($dodist++,shift,next);
$ARGV[0] =~ /^-n/ && ($n=' -n',shift,next);
$ARGV[0] =~ /^-l/ && ($l=' -l ' . $ARGV[1],shift,shift,next);
last;
}
$systype = shift; # get name representing set of hosts
while ($ARGV[0] =~ /^-/) { # we allow switches afterwards too
$ARGV[0] =~ /^-h/ && ($showhost++,$silent++,shift,next);
$ARGV[0] =~ /^-s/ && ($silent++,shift,next);
$ARGV[0] =~ /^-d/ && ($dodist++,shift,next);
$ARGV[0] =~ /^-n/ && ($n=' -n',shift,next);
$ARGV[0] =~ /^-l/ && ($l=' -l ' . $ARGV[1],shift,shift,next);
last;
}
if ($dodist) { # distribute input over all rshes?
`cat >/tmp/gsh$$`; # get input into a handy place
$dist = " </tmp/gsh$$"; # each rsh takes input from there
}
$cmd = join(' ',@ARGV); # remaining args constitute the command
$cmd =~ s/'/'"'"'/g; # quote any embedded single quotes
open(ghosts, '/etc/ghosts') || die 'No /etc/ghosts file';
# /etc/ghosts drives the rest
$one_of_these = ":$systype:"; # prepare to expand "macros"
if ($systype =~ s/\+/[+]/g) { # we hope to end up with list of
$one_of_these =~ s/\+/:/g; # colon separated attributes
}
line: while (<ghosts>) { # for each line of ghosts
s/[ \t]*\n//; # trim leading whitespace
if (!$_ || /^#/) { # skip blank line or comment
next line;
}
if (/^([a-zA-Z_0-9]+)=(.+)/) { # a macro line?
$name = $1; $repl = $2;
$repl =~ s/\+/:/g;
$one_of_these =~ s/:$name:/:$repl:/; # do expansion in "wanted" list
next line;
}
# we have a normal line
@attr = split; # a list of attributes to match against
# which we put into an array
$host = $attr[0]; # the first attribute is the host name
if ($showhost) {
$showhost = "$host:\t";
}
attr: while ($attr = pop(attr)) { # iterate over gh array
if (index($one_of_these,":$attr:") >=0) { # is host wanted?
unless ($silent) { print "rsh $host$l$n '$cmd'\n"; }
$SIG{'INT'} = 'DEFAULT';
if (open(pipe,"rsh $host$l$n '$cmd'$dist |")) { # start rsh
$SIG{'INT'} = 'cont';
while (<pipe>) { print $showhost,$_; } # show results
close(pipe);
} else {
$SIG{'INT'} = 'cont';
print "(Can't execute rsh.)\n";
}
last attr; # don't select host twice
}
}
}
unlink "/tmp/gsh$$" if $dodist;
# here are a couple of subroutines that serve as signal handlers
sub cont {
print "\rContinuing...\n";
}
sub quit {
$| = 1;
print "\r";
$SIG{'INT'} = '';
kill 2, $$;
}
--------------------------------------------------------------------------------
Gsh (and gcp) runs off the /etc/ghosts file, which looks like this:
--------------------------------------------------------------------------------
# This first section gives alternate sets defined in terms of the sets given
# by the second section.
all=sun+mc+vax
baseline=sun+mc
sun=sun2+sun3
vax=750+8600
passwd=devvax+chief+mc
# This second section defines the basic sets. Each host should have a line
# that specifies which sets it is a member of. Extra sets should be separated
# by white space. (The first section isn't strictly necessary, since all sets
# could be defined in the second section, but then it wouldn't be so readable.)
devvax 8600 src
cdb0 sun3 sysdts
cdb1 sun3 sysdts
cdb2 sun3 sysdts
chief sun3 src
tis0 sun3
manny sun3 sysdts
moe sun3 sysdts
jack sun3 sysdts
disney sun3
huey sun3 nd
dewey sun3 nd
louie sun3 nd
bizet sun2 src sysdts
gif0 mc src
mc0 mc
dtv0 mc
--------------------------------------------------------------------------------
Enough of gsh. How about you want to remove files with find, but don't want
to exec rm on every file? I just did this today in some of my news directories.
find . -mtime +14 -print | perl -n -e 'chop;unlink;'
I could have done the equivalent by running the find from within a perl script.
Note that the open statement opens up a pipe.
#!/bin/perl
open(goners,"find . -mtime +14 -print|");
while (<goners>) {
chop;
unlink;
}
How about transforming that into a tool that will remove anything older than
a specified number of days in a specified directory?
#!/bin/perl
die "Usage: euthanasia directory days" unless $#ARGV == 1;
($dir, $days) = @ARGV; # assign array to list of variables
die "Can't find directory $dir" unless chdir $dir;
open(goners,"find . -mtime +$days -print|") || die "Can't run find";
while (<goners>) {
chop;
unlink;
}
I mentioned my anomaly reporting system earlier. Here is the script that scans
a particular system for filesystems that are almost full. Note the use of
the C preprocessor to isolate Masscomp specific code.
--------------------------------------------------------------------------------
#!/bin/perl -P
(chdir '/usr/adm/private/memories') || die "Can't cd.";
`df >newdf`;
open(Df, 'olddf');
while (<Df>) {
($fs,$kbytes,$used,$avail,$capacity,$mounted_on) = split;
next if $fs =~ /:/;
$oldused{$fs} = $used;
}
open(Df, 'newdf') || die "scan_df: can't open newdf";
while (<Df>) {
($fs,$kbytes,$used,$avail,$capacity,$mounted_on) = split;
next if $fs =~ /:/;
$oldused = $oldused{$fs};
next if ($oldused == $used && $capacity < 99); # inactive filesystem
if ($capacity >= 90) {
#if defined(mc300) || defined(mc500) || defined(mc700)
$_ = substr($_,0,13) . ' ' . substr($_,13,1000);
$kbytes /= 2; # translate blocks to K
$used /= 2;
$oldused /= 2;
$avail /= 2;
#endif
$diff = int($used - $oldused);
if ($avail < $diff * 2) {
$mounted_on .= ' *';
}
next if $diff < 50 && $mounted_on eq '/';
$fs =~ s|/dev/||;
if ($diff >= 0) {
$diff = '(+' . $diff . ')';
}
else {
$diff = '(' . $diff . ')';
}
printf "%-8s%8d%8d %-8s%8d%7s %s\n",
$fs,$kbytes,$used,$diff,$avail,$capacity,$mounted_on;
}
}
rename('newdf','olddf');
--------------------------------------------------------------------------------
Well, that's enough examples for now. In terms of speed, perl almost always
beats awk and usually beats sed. It's a superset of both awk and sed in
terms of capabilities. (That certainly makes the awk-to-perl and sed-to-perl
translators work more easily--in fact, some of the features of perl are there
simply to ease the translation process. I wasn't going to add a "goto" except
that the sed-to-perl translator needed one. There's a way to make arrays
have either origin 0 like C, or origin 1 like awk. Etc.)
As for reliability, perl has been in heavy use for over a year and a half.
Some of the design of perl facilitates adding new keywords without blowing
existing scripts out of the water. Furthermore, perl has a regression test
suite so that I know immediately if I've destroyed a previously available
capability. So you needn't worry too much about the next version of perl
blowing your old scripts out of the water.
Well, enough for now.
Larry Wall
lw...@jpl-devvax.jpl.nasa.gov