The execit Programs

[previous] [next] [table of contents] [index]

The execit program lets you make multiple versions of MH commands. For an introduction, see the Section Setup Before You Make First New Version. You can see the program and include files by clicking on the links in the text below (you might want to open them in a separate browser window).


The main program, execit.c, is written in the original (pre-ANSI) C programming language; you may need to do a little editing if you have an ANSI C compiler that doesn't understand "old C." The other files are: The files are in this book's online archive file; the directory name is old-edition2/execit.


As Chapter 10 explains, MH programs check the name they're invoked with (from their argv[0]) and change the way they work. The easiest way to make this happen with system programs is to make a new link (symbolic or "hard") to the program's executable code, like this:
% ln /usr/local/bin/folder /usr/myhome/bin/folderz
Then, you can run folder with the name folderz.

That method has some problems. You can only make hard links (ln) if you have access to a directory on the same filesystem as the system executables. And some systems don't have symbolic links (ln -s). That's when you need execit. execit lets you define a table of system commands and the names you want to run them with. Then, you make a link to execit with the name of the program you want to run. It invokes the system program with the name you use. This way, you get fast execution of a system program with your own name. And, if you make new hard links to execit to define new program names, the links take almost no more filesystem space.

Here's an example of how to set up execit so it will run the program /usr/local/mh/repl, but make repl think its name is replx:

  1. Edit the file execit.include and add a new line like this:
    "replx", "/usr/local/mh/repl",
    The second string should be where repl is located on your system. (the Chapter Key Parts of the UNIX Filesystem has more information.) Be sure to make the line look just like that: quotes (") and commas (,). The execit.include file is read into the xref structure when you compile execit.c; the script also reads it.
  2. Recompile this program, something like this:
    % cc -o execit execit.c
  3. If there were no errors, run the script. It will make a link to execit named replx, by running a command like this:
    ln execit replx
    If you run ls -li, you can be sure previous links to execit still exist:
    % ls -li execit replx tscan
     2379 -rwx------  3 jdpeek  35982 Feb 10 22:14 execit
     2379 -rwx------  3 jdpeek  35982 Feb 10 22:14 replx
     2379 -rwx------  3 jdpeek  35982 Feb 10 22:14 tscan
     ^^^^             ^               ^^^^^^^^^^^^
     SAME           SAME                 TODAY'S
     i-NUMS      LINK COUNT           DATE AND TIME
    Delete any old links (that you've removed from the execit.include file).
  4. You'll probably want an entry in your MH profile that looks like this:
    replx: -switches -go -here
    Now, assuming the directory with the links is in your shell's search path, you can run replx and pass the switch -query to it this way:
    % replx -query

The shell script reads the execit.include file and automatically builds the links to execit. When you first install, you'll need to edit this line for your system:

dest=/xxx/yyy/bin	# WHERE YOUR LINKS SHOULD GO

[Table of Contents] [Index] [Introduction to execit] [Previous: Explanation of edprofile] [Next: Explanation of fols]

Last change $Date: 1996/06/06 15:09:44 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Jerry Peek <>