Running Rexx scripts on DOS.
"Rexx (restructured extended executor) is a high-level programming language developed at IBM by Mike Cowlishaw. Both proprietary and open source Rexx interpreters exist for a wide range of computing platforms, and compilers exist for IBM mainframe computers. Rexx is used for scripting, application macros and application development. As a general purpose scripting language, Rexx is considered a precursor to Tcl and Python."
The paragraph above is how Rexx is described in the corresponding article of Wikipedia. The first implementation of Rexx was made freely available over IBM's world-wide internal network in late 1979. So, it's very old, you may say. Maybe, but it has a great strength: Rexx is powerful yet easy to read, write, and maintain...
This article is about using Rexx on DOS. If you want to know more about Rexx on Windows, please have a look at my tutorial Developing Rexx applications on Windows 11.
IBM Rexx on the latest versions of PC-DOS.
PC-DOS 7.0, as well as the special brand PC-DOS 2000, include by default a Rexx interpreter. If you want to run Rexx scripts on these platforms, just write the script and execute it.
Here is the code of a simple Rexx script to calculate the factorial of a number entered on the command line.
/* Factorial */
parse arg X
say X"! =" FACT(X)
exit
FACT: procedure
parse arg N
if N = 0 then
return 1
else
return FACT(N-1) * N
I named the script FACT.REX and put it into the directory C:\DEVEL\REXX. The screenshot shows the script, opened in E, the IBM text editor, included with PC-DOS 2000.
![]() |
Note: It was only later that I noticed that IBM Rexx uses the extension .RX (and not .REX) for Rexx scripts...
To execute the script, cd to the directory C:\DEVEL\REXX, and run a command like:
rexx fact.rexx 6
![]() |
Here is another script; it calculates the square root of a number with a given number (20) of decimal digits.
/* Square root */
parse arg X
numeric digits 25
say "sqrt(x) =" SQRT(X, 20)
exit
SQRT: procedure
parse arg R, D
if D = "" then D = 9; numeric digits D
parse value FORMAT(R,,,,0) with R "E" Exp
if Exp = "" then Exp = 0
if (Exp // 2) <> 0 then
if Exp > 0
then do; R = R * 10; Exp = Exp - 1; end
else do; R = R / 10; Exp = Exp + 1; end
X = 0.5 * (R + 1)
do forever
NewX = 0.5 * (X + R / X)
if X = NewX then return X * 10 ** (Exp % 2)
X = NewX
end
The screenshot shows a sample execution of the script.
![]() |
IBM Rexx on MS-DOS 6.22.
The version of IBM Rexx, included with PC-DOS 7.0, works well on MS-DOS 6.22. You can download an ISO of PC-DOS 7.0 from the Internet Archive. In the CD directory \PCDOS70\DOSFILES, you find the files REXX.EXE and REXXDUMP.EXE. On your MS-DOS machine, copy them to a directory that is in your path (I used C:\DOS). That's all you need to do to run Rexx scripts on MS-DOS 6.22!
Note: The PC-DOS 7.0 CD also includes several Rexx scripts (files with extension .RX), that you might want to copy to your MS-DOS machine.
Here is the code of a script that calculates the date of Easter for the actual or a given year.
/* Computes easter for a specific year
from Scientific American, Mar 2001 p82
*/
parse arg Year
if Year = '' then
Year = left(date( 'S' ), 4) /* get this year */
A = Year // 19
B = Year % 100
C = Year // 100
D = B % 4
E = B // 4
G = ((8 * B) + 13) % 25
H = ((19 * A) + B - D - G + 15) // 30
M = (A + 11 * H) % 319
J = C % 4
K = C // 4
L = ((2 * E) + (2 * J) - K - H + M + 32) // 7
N = (H - M + l + 90) % 25
P = (H - M + l + N + 19) // 32
if N = 3 then
say 'March' right(P, 2)',' Year
else
say 'April' right(P, 2)',' Year
The screenshot shows a sample execution of the script.
![]() |
Regina Rexx on FreeDOS.
If you are searching for a recent version of Rexx for DOS, than Regina Rexx is probably the best choice. Regina Rexx is fully under development. Available for lots of platforms, the actual version (June 2025: version 3.9.7) is also available as 32-bit program for DOS. You can download the installation files as ZIP archive from Sourceforge. In my case the archive is named regina397dos4gw.zip.
I unpacked the archive on my Windows 10 and burned them onto a CDROM (aka created an ISO containing the archive content) to transfer them onto my FreeDOS machine. On FreeDOS, I created the directory C:\REGINA, and copied the archive content to this directory using xcopy. The screenshot shows the content of the installation directory.
![]() |
Here is the code of a script that calculates the N first items of the Fibonacci numbers series.
/* Fibonacci numbers */
parse arg X
I = 1
do while I <= X
say format(I, 2) " " format(FIB(I), 4)
I = I + 1
end
exit
FIB: procedure
parse arg N
if N = 0 | N = 1 then return N
A = 0; B = 1
do N - 1
parse value(B (B + A)) with A B
end
return B
I have lots of compilers and interpreters installed on my FreeDOS machine and I keep all my sources together in some subdirectories of D:\DEVEL. So, for the Regina Rexx sources, I created D:\DEVEL\REXX, and placed my Fibonacci script FIB.REX to there.
Also, on my FreeDOS machine, I create batch files to be used to compile/interpret my sources. These batch files do several things:
- Adding the directory containing the compiler/interpreter to the PATH.
- Setting the custom environment variable DEVEL to a value identifying the programming language.
- Setting the current directory to the directory that contains the source files.
- Running the compiler/interpreter, or starting the IDE/editor that I use with this programming language.
Here is the content of my REXX#.BAT (to be placed in a directory that is in the PATH; in my case C:\FREEDOS\BATCH). Using this batch file, allows to execute my Rexx scripts independently from the directory where I am currently in.
@echo off
set path=%path0%;C:\REGINA
set DEVEL=rexx
D:
cd \DEVEL\REXX
C:\REGINA\regina.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
Note: path0 is a custom environment variable set equal to path in my FDAUTO.BAT. Using this variable prevents that C:\REGINA is added to the actual path multiple times (each time the batch file is executed). If you don't use path0, you should save the old path to some environment variable at the beginning of the batch file, and restore the old path at the end of the script.
However, trying to execute the Fibonacci number script with the command
rexx fib.rex 20
results in the error message Can't run DOS/4G(W).
The reason for this is that Regina Rexx for DOS actually is a 32-bit program, using the DOS/4GW extender, and on my FreeDOS machine the extender executable isn't available in any directory being in the PATH.
I suppose that there are several websites where you can download the extender (search for a file called dos4gw.exe). I, myself, used the file from the Watcom C/C++ distribution (where you find it in the BINW subfolder of the installation directory). The extender has to be in the PATH. One possibility to put it there is to copy the file dos4gw.exe to C:\REGINA (alternative: copying it to your FreeDOS BIN directory should make it available to all programs that need it...).
With the extender being accessible by regina.exe, the execution of the Fibonacci number script works fine. The screenshot shows the program output for the 20 first numbers.
![]() |
Other Rexx for DOS distributions.
BRexx, by Vassilis N. Vlachoudis, is a lightweight open source multi-platform Rexx interpreter. It is said not as powerful as alternatives such as Regina Rexx. On the other hand, it is notably lighter and faster than most other Rexx distributions.
You find a full description of BRexx, including download links (FTP only) at gwdg.de. There seems to be a 16-bit version and a 32-bit, DJGPP based version available. I did not (yet) try out BRexx...
If you find this text helpful, please, support me and this website by signing my guestbook.