gale.org
Home > Documentation > for Users > gsub > Contrib@

Synopsis

gsub [-habekKnr] [-o address] [-f rcprog] [-l rclib] [-p state] categories...


Description

Subscribe to messages on the Gale messaging system. Command-line arguments specify which messages to receive and how to format the messages; messages are written to standard output. By default, gsub runs in the background so that you can continue your work; messages will be displayed on your terminal as they occur. (This is similar to the way "write" or "talk" deliver messages to your screen.) If gsub is run twice on the same terminal, the second gsub will terminate the first, so you can simply re-run "gsub" with different parameters or environment variables to reconfigure your session.

Without command-line arguments or variables (like GALE_GSUB or GALE_SUBS) to the contrary, gsub will subscribe to your personal messages only. Categories specified on the command line are added to the subscription list.

-a
Operate (a)nonymously. By default, when gsub is running on a terminal, it announces its "presence" so that interested users can see that you are logged on. If you want more privacy (or otherwise don't want this gsub's presence recorded), the "-a" flag puts gsub in "stealth mode"; short of sniffing the network, nobody will know that it's running.
-A
(A)lways announce "presence". (Normally gsub doesn't announce itself if output is directed to a file.)
-b
Do not (b)eep. By default, gsub rings the console bell when a private message is received; this flag silences the bell. For more sophisticated control over message formatting and notification you can use a custom "gsubrc" (see the section on gsubrc configuration below).
-e
Esch(e)w any default subscriptions (including personal messages). With this flag, you must supply categories on the command line, and gsub will only subscribe to these categories.
-f gsubrc
Select a particular gsubrc (f)ile to run instead of "$HOME/.gale/gsubrc". If the specified path is relative, it will be relative to "$HOME/.gale". See gsub configuration.
-k
Do not (k)ill other gsub processes, even if they are running on the same terminal. You can use this to have multiple gsubs running at once.
-K
(K)ill other gsub processes and terminate immediately. Use this to "log out" from Gale.
-l rclib
Select a particular gsubrc.so (l)ibrary to load. See gsub configuration and the "gsubrc.h" header file.
-n
Do (n)ot run in the background. The command will not return until gsub is terminated.
-o address
Listen to private messages for "address" as well as your own. You will need to possess the private key for "address" in order to decrypt these messages.
-p state
Set the default "presence state" that other users will see. This is "in/present" by default, but can be set to any string (such as "out/to/lunch" or "back real soon").
-r
Run the default internal gsubrc and exit. See gsub configuration.
categories...
Subscribe to these categories. Multiple categories may be separated with a colon (":") or listed as separate arguments. See the tutorial on categories for more information.

Customization

Gsub's behavior may be customized with several configuration variables: GALE_CONF, GALE_DIR, GALE_DOMAIN, GALE_GSUB, GALE_PROXY, GALE_SUBS, GALE_SYS_DIR.

Using gsubrc

You can control what happens to messages by writing a "gsubrc". This is a program, written in any programming language you like (but usually a scripting language like Perl or the Bourne shell), which is executed every time a message is received; gsub looks for this program in in "$HOME/.gale/gsubrc" by default. The message's attributes are set in environment variables, and the message body is sent to the program's standard input. The program can output the message to the terminal (formatted however it wants), or it can log the message to a file, respond automatically to the message, or take any other action the user desires.

If no such program exists, gsub uses an internal message formatter. It is often useful to call this formatter from your own gsubrc, so you can do so by running "gsub -r". For example, a simple "killfile" gsubrc might examine the message's sender, terminate immediately if the sender is "undesirable", or otherwise call "gsub -r" to format the message exactly as it would have been otherwise.

The name of the gsubrc program can be changed with the "-f" argument, so you can switch between multiple formatters. Advanced programmers can specify a shared library with "-l" that will be loaded by gsub and called to format messages. Refer to the "gsubrc.h" file installed in the system include directory for details of the shared library gsub interface.

gsubrc Environment

The best way to learn how to write "gsubrc" scripts is to run "gsub -f /usr/bin/env" and send yourself a message. All active configuration variables will be in the environment (even if they came from a configuration file). Additional variables describe the message. "$GALE_CATEGORY" contains the message category and "$GALE_SIGNED" contains the sender's verified ID (if any). Lots of variables of the form "$HEADER_..." contain information about the message's content.


Examples

gsub
Subscribe to your private messages. Gsub will run in the background, writing messages to your terminal as they arrive.
gsub pub.stuff
Subscribe to private messages as well as anything posted to the "pub.stuff" category.
gsub > log
Record a log of messages sent to you in "log". This command will not run in the background by default, and it will not announce its presence.
gsub -e pub:-pub.boring:pub.boring.holes
Subscribe exclusively to messages in the "pub" category, but do not receive anything posted to the "pub.boring" category, but do receive messages posted to the "pub.boring.holes" category. Because, y'know, holes aren't really boring.

See Also

gsend, Categories, Contributed gsubrc Archive