About the Perl Scripts
The scripts live in the Scripts directory. They are
designed to be run from the gateway's directory (the
directory that Scripts is a member of); they won't work
if you try to run them from elsewhere.
- accounts.pl - list account information in columnar
form
- select.pl - select accounts by date or regular
expression
- columns.pl - delete and rearrange columns of
information
- collapse.pl - collapse the first column into one
line
- readable.pl - format the information for
readability
"accounts.pl" extracts account information from the
UserFiles directory; the other scripts operate on this
information. To try it out, type
perl Scripts/accounts.pl
To see only the accounts created since 1 March (created
after, -ca) and not used since 1 April (used before, -ub),
type
perl Scripts/accounts.pl | perl Scripts/select.pl -ca 1
March -ub 1 April
To delete those accounts, use "collapse.pl" to put the
account names into the right form for "rm".
rm -rf `perl Scripts/accounts.pl | perl
Scripts/select.pl -ca 1 March -ub 1 April | perl
Scripts/collapse.pl 'UserFiles/'`
As you see, the commands can get rather long. If you do
this sort of thing often, you might want to... write a script
for it.
Each script has header comments which explain what it's for
and how to use it. Here's a brief guide.
accounts.pl [-n]
Extract user account information from the UserFiles
directory and print it, one account per line, in
tab-delimited columns. The fields extracted are account name,
real name, e-mail address, organization, time created, and
time last used. If you specify -n, the two header lines that
identify the fields are not printed.
For example,
perl Scripts/accounts.pl
select.pl [-ca <date>] [-cb <date>] [-ua <date>]
[-ub <date>] [+|-<n> <regexp>]
Given account information in the form provided by
"accounts.pl", select some of the accounts, printing them to
standard output, and ignore the rest.
- -ca <date> - accounts created after <date>
- -cb <date> - accounts created before <date>
- -ua <date> - accounts last used after <date>
- -ub <date> - accounts last used before <date>
- +<n> <regexp> - accounts matching <regexp>
in column <n>
- -<n> <regexp> - accounts not matching <regexp>
in column <n>
If you give more than one condition, you get only accounts which meet all
of the conditions.
For example, to select accounts which have a real name
(column 2) starting with "Jay",
perl Scripts/accounts.pl | perl Scripts/select.pl +2
'^Jay'
columns.pl [<n1> [<n2> ...]]
Select given columns from tab-delimited input (it works
for any line-by-line tab-delimited data). The leftmost column
is column 1. This lets you not only choose a subset of the
columns in the input, but also duplicate and rearrange
columns.
For example, to include only the real name (column 2) and
e-mail address (column 3),
perl Scripts/accounts.pl | perl Scripts/columns.pl 2
3
collapse.pl [<prefix> [<suffix>]]
Collapse the first column into one line, suitable to be
included in a unix shell command line. If you give a prefix,
it is prepended to each item; if you also give a suffix, it's
appended.
To see how it works, try
perl Scripts/accounts.pl | perl Scripts/collapse.pl [ ]
A more useful task is to send e-mail to all account
holders. Note the -n argument to "accounts.pl", so that we don't
send e-mail to a header line.
mail `perl Scripts/accounts.pl -n | perl Scripts/columns.pl
3 | perl Scripts/collapse.pl` <announcement
readable.pl
Convert tab-delimited data to (hopefully) human-readable,
justified, space-delimited columns. If the lines are short
enough, sometimes the result actually is human-readable.
For example, to see the real name and e-mail address,
perl Scripts/accounts.pl | perl Scripts/columns.pl 2 3 |
perl Scripts/readable.pl
Jay Scott,
jay@forum.swarthmore.edu
15 April 1995