Basics and Installation
One nice feature that *nix systems have is the ability to indicate which shell interpreter to use from within the script itself. The the first line of the script start with characters #!, then the rest of the string, up to the first space, indicates the directory and interpreter name. In TSO/E, it is similar to adding a /* REXX */ in the first line to indicate it's a rexx exec vs a standard CLIST.
There are many good free rexx interpreters for various non-mainframe environments. The one I've chosen to use and write about is the Regina Rexx interpreter. There is a pre-buit version for the Mac that is easy to install.
As much as I like Regina rexx (from now on simply Regina), its Mac OS X documentation is sometimes misleading or simply wrong. Have a feeling the documentation simply needs to be updated for the newer versions of Mac OS X. I'm using Snow Leopard (10.6), so anything in these Regina inspired next few blogs will pertain only to that level of Mac OS X.
Before continuing, I'd make myself somewhat familiar with using the Terminal application inside of the Utilities sub-directory within Applications. Apple has also provided quite a nice document titled The Shell Scripting Primer.
Once you install Regina, you need to customize the installation for your use. The customization steps are what I personally recommend, but are not necessarily the only or the best for your situation. If anything, I hope it provides a good starting point. So, the following steps are best for me, adjust for yourself as necessary or if preferred.
1) Create a "Shell" subdirectory within your home directory. I also listed it my Finder's sidebar Places list. This is where I keep any shell scripts I write, regardless of interpreter.
2) There are a couple of variables that need to be defined as part of the initial default shell. There is a hidden directory and file in your home directory. The hidden directory is .MacOSX. There is a plist file aptly named environment.plist within the .MacOSX directory. If there is no .MacOSX or environments.plist entries, you an simply create them from the normal TextEdit program. There is a Snow Leopard trick to see hidden files and directories. Once in the normal Open Dialog, just press the key combination of command-shift-period, and that will toggle on and off the display of hidden files and directories. This key combination works for pretty much all applications with the exception of the Finder. You can also use the Properties List Editor as well. Below is the contents of my environments.plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LIBPATH</key>
<string>/usr/lib</string>
<key>PATH</key>
<string>/users/ttranter/shells:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin</string>
</dict>
</plist>
My home directory is /users/ttranter, please alter according to the name of your home directory. Also make sure you include any other PATH contents that currently exist. See the Shell Primer document for more information. The LIBPATH variable is used by Regina to locate various Dylds and other components of the interpreter. This normally should be set to /usr/lib. The first directory entrie in my PATH statement indicate where my shell scripts reside. Some people create a rexx subdirectory within /usr (example /usr/rexx) and include that entry within the PATH statement as well for any rexx execs that can be globally used by any user on the Mac.
3) Once ~/.MacOSX/environments.plist has either been altered or created, log-out then log back on. Reboot is not necessary. Frankly, Don't even know if re-logging is really necessary. For my Mac, I found it was. Better safe the sorry.
Okay, installed and customized! Below is a small rexx execs. Use TextEdit (or equivalent like TextWrangler) and place it inside of the Shells directory as reginatest.
#!/usr/bin/regina
/* The Regina Rexx Test Exec */
parse version whoami
say "Executing Interpreter --" whoami
exit 0
Make sure you issue the chmod u+x reginatest too! The output should look similar to:
MacIron:~ ttranter$ reginatest
Executing Interpreter -- REXX-Regina_3.5(MT) 5.00 31 Dec 2009
MacIron:~ ttranter$
Think that's enough for this blog. Good luck! Next couple of blogs will describe a few interesting rexx execs I've written for the Mac!
No comments:
Post a Comment