Tuesday, March 1, 2011

First Example Rexx Exec

In the previous Blog, I described how to install and customize the Regina Rexx interpreter for Mac OS X Snow Leopard.  Any comments or installation instructions are based upon that blog.

Today, I thought I'd share a short exec that I use in place of the LS command.  Coming from a Windows/DOS world, I kind of missed my DIR command.  This seems like a reasonable replacement.  Hope you find it useful!


#!/usr/bin/regina
address SYSTEM "ls -le" with OUTPUT STEM wdir.
if rc = 0 then do l = 2 to wdir.0
   say wdir.l
end
address SYSTEM "pwd" with OUTPUT STEM wdir.
if rc = 0 then do
   say
   say "Current directory is:" wdir.1
   say
end
exit 0

Save the above text as ~/Shells/dir then issued the terminal commands:

cd ~/Shells
chmod u+x dir


Once done, you can simply type in DIR, just like good old DOS and see the directory listing.  Below is the output when using DIR to list my home directory:


MacIron:~ ttranter$ dir
drwxr-xr-x  24 ttranter  staff     816 Feb 27 15:23 Backed Up
drwxr-xr-x   3 ttranter  staff     102 May  3  2010 CPA
-rw-r--r--@  1 ttranter  wheel  518992 Feb 24 17:14 CUPS-PDF Spool
drwx------   4 ttranter  staff     136 Feb 28 18:07 Desktop
drwx------  28 ttranter  staff     952 Feb 18 23:06 Documents
drwx------   5 ttranter  staff     170 Mar  1 13:53 Downloads
drwx------  55 ttranter  staff    1870 Feb 28 11:22 Library
drwx------   7 ttranter  staff     238 Feb  7 23:44 Movies
drwx------   8 ttranter  staff     272 Mar  2  2010 Music
drwx------  14 ttranter  staff     476 Feb  6 11:25 Pictures
drwxr-xr-x  25 ttranter  staff     850 Feb 27 23:27 Projects
drwxr-x-wx   6 ttranter  staff     204 May 17  2010 Public
drwxr-xr-x@ 31 ttranter  staff    1054 Mar  1 21:30 Shells
drwxr-xr-x+  6 ttranter  staff     204 Mar 15  2010 Sites
 0: group:everyone deny delete
-rw-r--r--@  1 ttranter  staff  519112 Feb 25 23:29 eBooks


Current directory is: /Users/ttranter


MacIron:~ ttranter$ 

Hope you find it useful!

No comments:

Post a Comment