SCBIND - A "compiler" for shell scripts, by Al Williams (alw@al-williams.com).

This is a little program I wrote some years ago that allows you to "compile"
shell scripts. Well, OK, you don't really compile them. The way the program
works is that it creates and compiles a C program with your script scrambled
up inside. When you run the program, it runs the shell of your choice, and
calls it, feeding it input from a named pipe. This allows the program to
feed commands to the shell, while the shell's stdin is still the terminal 
(or wherever you think it is).

What You Need
=============
/bin/sh
/bin/cc
/bin/head

INSTALLATION
============
If you use i386 Linux ELF format executables, you are ready to go
just by unpacking the whole thing into the directory of your choice.
The compiler expects to find all the files in the same directory, but
you can change that by editing binds (a shell script).

If you want to or need to recompile, just type:
 make

You can type
  make clean
if you want to delete everything first.


Easy Start
==========
Take your favorite shell script, and copy it to the directory
that contains binds, xsh.c, decode.c, etc. and rename it to have 
a .sh extension.If it doesn't use /bin/sh, make sure it has 
a #! line as line #1 (for example, #!/bin/tcsh). 
Suppose the script's name is hilo.sh (the example in this directory).
Then you enter:

   binds hilo

Notice I did not include the .sh extension. This creates hilo.c and hilo (an
executable produced by cc). Run that executable, and the script runs! If
you cat the executable, you won't be able to easily discern the script
command, or even that it is a script!

More Involved Use
=================
The binds shell script takes two optional arguments. First, you can
override the name of the shell. The second argument allows you to
set an option passed to the shell (usually -i).

If you don't supply these arguments, the script uses the first line
of the file for the shell name (striping the #! part). 
If that doesn't appear correct, the program uses /bin/sh.

If you don't provide an option, the program automatically uses -i. For most
shells, this permits them to respond to signals even though they think they
are not interactive. If you use '' for the option, at least on bash, you
will disable ^C and other signal handling (which might be a feature).

The decode.c file contains the lightweight encryption algorithm. You can
use anything here as long as it is reversible. That is, if you call it
twice in a row, you wind up with the same string you started with. At the
very least you should change the encryption key so that everyone who has
access to the source will have some small difficulty cracking your scripts.

More Details
============
The actual program doing the work is scbind. This program takes
the input file name, the output file name, the name of the program
(for error reporting in the resulting program), the name of the shell
(must include the #!), and an optional argument (which is nothing if 
omitted). Using scbind, you can make custom scripts like binds to
handle any special case you want. Then you can compile them!

If you use scbind directly, remember that you must include #! with the
shell name. Also, if you include #! on the command line, you probably 
have to escape it, as in:

   scbind hilo.sh hilo.c hilo \#\!/bin/bash -i


MISC
====
* This Software is distributed under the GPL (see file COPYING).

Who is Al Williams?
===================
If you work with Windows, you might know some of my books or magazine
columns. I am the C++ columnist for Visual Developer (formerly 
PC Techniques), the Java columnist for Web Techniques, and the former
20/20 columnist for the defunct Dr. Dobb's Sourcebook.

My books include MFC 5 Black Book, Developing ActiveX Web Controls, 
DOS And Windows Protected Mode, and DOS 5: A Developer's Guide. Note,
however, that I am not Al Stevens, another DDJ author.

Want to know more (including classes I teach or consulting arrangements)?
Check out http://www.al-williams.com

