Calling dos program from OS2 REXX 
Author Message
 Calling dos program from OS2 REXX

Is there anything in particular I need to do to call a dos program from
a REXX cmd if I am running an extension?

I am using a freeware program to have PM capabilities in REXX. Right
before I call the dos program I do a "address cmd".

Should I use "start" for the dos program?



Sun, 28 Sep 1997 03:00:00 GMT  
 Calling dos program from OS2 REXX
HI -- my gateway ate your name, but....

Quote:
>>Is there anything in particular I need to do to call a dos program

from a REXX cmd if I am running an extension?<<

Nope.  Whatever you can type at the command prompt can be a line in
your rexx.  To keep it from getting interpreted, put it in quotes.  For
example, to run the DIR command, put the line

"dir"

in your rexx.

Quote:
>>I am using a freeware program to have PM capabilities in REXX. Right

before I call the dos program I do a "address cmd".<<

The "address cmd" is probably unnecessary; rexxes usually run in the
command environment unless you have changed it.  To check, put

say address()

in the rexx and see what gets said.

Quote:
>>Should I use "start" for the dos program?<<

If you put the line

"start dir"

in the rexx, this will kick off an asynchronous thread, and the rexx will go on
about its business without waiting for the "dir" to complete.  Probably not what
you want.

- Peter



Sun, 28 Sep 1997 03:00:00 GMT  
 Calling dos program from OS2 REXX

Quote:
>>>Is there anything in particular I need to do to call a dos program
>>>from a REXX cmd if I am running an extension?
>Nope.  Whatever you can type at the command prompt can be a line in
>your rexx.  To keep it from getting interpreted, put it in quotes.  For
>example, to run the DIR command, put the line
>"dir"

This extension I am using replaces the process(?) processor. When I did
address() it told me RXDLG.

Quote:
>The "address cmd" is probably unnecessary; rexxes usually run in the
>command environment unless you have changed it.  To check, put

As the address() function returned this extension does not run in the
command environment. I had also tried another rexx program and I could
not do os2 commands such as copy until I did a address cmd.

Quote:
>"start dir"
>in the rexx, this will kick off an asynchronous thread, and the rexx will go on
>about its business without waiting for the "dir" to complete.

As long as I get the program (a game actually) to run  it is ok if it is on a
separate thread.

I have tried: name, name with '', name with "" and also tried several versions
of the the start command.

The extension I am using is called RXdlg (rexx dialog). It gives me PM functions
from my rexx programs. To run the cmd with this extension I need to call
an exe that runs the cmd.

If I run the game by itself from a regular rexx program it works.



Mon, 29 Sep 1997 03:00:00 GMT  
 Calling dos program from OS2 REXX

Quote:
>HI -- my gateway ate your name, but....

>in the rexx, this will kick off an asynchronous thread, and the rexx will go on
>about its business without waiting for the "dir" to complete.  Probably not what
>you want.

This is a little off the original question, but...I found a really neat trick for
executing commands (DOS or OS/2) in an asynchronous thread where the caller
is able to determine when the command has completed.  Pipe the output to
a file, such as <command>.OUT.  Wait a few seconds (depending upon the
command or program you are executing), then start trying to open the output
file periodically.  When the file can be opened, the command has completed.
The STDOUT output is now in the file (you can also redirect STDERR here).
This is especially useful for checking for completion codes in user-written
programs.  I used it to automate scheduling of a Microfocus COBOL jobstream
on an OS/2 server - from CA7 on the mainframe!

Here's an example:

/* REXX */

..<housekeeping junk>...

ADDRESS CMD "MYPROG >MYPROG.OUT"
Call SysSleep 5
Do Until STREAM("MYPROG.OUT","C","OPEN")="READY:"
 Call SysSleep 5
End;

Do While Lines("MYPROG.OUT")=1
 CheckLine=LINEIN("MYPROG.OUT")
 Select;
 When... conditional checking of output messages
 Otherwise...
 End;
End;

/-----------------------------------------------------------
/ Mike O'Brien
/ Senior Consultant
/ Legent Corporation  



Mon, 29 Sep 1997 03:00:00 GMT  
 Calling dos program from OS2 REXX

Quote:
>The extension I am using is called RXDLG (rexx dialog).
>I had also tried another rexx script [written for RXDLG] and I could
>not do os2 commands such as copy until I did a address cmd.

Hello,
   I'm the guy who inflicted Rexx Dialog upon the unsuspecting public.
Maybe I can help you out here. (You should also check out the "Errors"
section of the Rexx Dialog manual, which explains why you've run
into the problem that you're experiencing). Because your REXX script
is being invoked by the executable RX.EXE (rather than the OS/2 shell), all
your REXX statements (that aren't recognized by the REXX interpreter
as built-in REXX commands such as STREAM, LINEIN, PARSE, etc) are
sent to Rexx Dialog's "REXX environment" rather than the OS/2 Shell's
REXX environment. Rexx Dialog understands its own commands such as
RXDLG, RXDEV, RXERR, etc. But, Rexx Dialog doesn't understand OS/2
Shell commands such as "copy", "dir", and the names of other OS/2
executables to run. If you've written a REXX statement that wants to
issue OS/2 Shell commands, or cause the OS/2 shell to launch another
program, you need to "address" that REXX statement to the OS/2 Shell's
REXX environment. You need to use the REXX "ADDRESS"
command to do that, and the name of the OS/2 Shell's REXX environment
is "CMD". You simply put this in front of the REXX statement that you
wish to direct to the OS/2 Shell (instead of Rexx Dialog). For example,
to issue the "dir" command from a Rexx Dialog script:

ADDRESS CMD "dir"

So, if you want to launch some executable via Rexx Dialog, you can do
it like this:

ADDRESS CMD "your executable's name here"

But, if you're launching an executable that doesn't complete its work
quickly and then terminate, it would be best to use the OS/2 Shell's
"start" command to launch that app (so that you don't inadvertently
lock up the PM Desktop by trying to manipulate a Rexx Dialog window
while that launched app was still running).

ADDRESS CMD "start" "your executable's name here"

You definitely can launch other app's from a Rexx Dialog script. I've
written some "REXX front-end's" for certain apps, which do just that.
But you do have to use the ADDRESS command to readdress particular
statements to the intended environment. If that intended environment
is the OS/2 Shell, then its enviroment name is "CMD". Other applications
that have a REXX interface will have their own unique environment names.
Rexx Dialog's environment name is "RXDLG" for example, which means that
some other REXX script (including not a Rexx Dialog script) could send
a particular REXX statement to Rexx Dialog (by prepending ADDRESS RXDLG
before the statement). Of course, you'd have to be issuing a command that
Rexx Dialog understands, such as RXMSG (and of course, the message box
could only pop up in a window that was opened by some other Rexx Dialog
script, because of the way that Rexx Dialog is designed). But, this
example is just to show you how REXX's ADDRESS command works, and what
it is used for. As more and more OS/2 executables incorporate REXX
interfaces allow REXX scripts to control the apps, you'll definitely need to
get familiar with the ADDRESS command.
   Anyway, if you have more questions about Rexx Dialog, you may as
well ask me. If I don't know the answer for that, then probably nobody
does



Tue, 30 Sep 1997 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Calling dos program from OS2 REXX

2. OS2 REXX CPU usage function call?

3. Calling Batch from Rexx/OS2

4. Calling Batch from Rexx/OS2

5. How to execute OS2 edit macro from a REXX program

6. REXX sample TELNET program in OS2

7. NT REXX assistance for OS2/VM REXX man

8. Call a REXX Exec and have it Address the calling program

9. Windows program call DOS program

10. rexx program calling cobol program

11. Calling a REXX program from a C program.

12. Calling REXX programs from within an assembler program

 

 
Powered by phpBB® Forum Software