· Jul 18, 2019

How to execute a program from a program and capture the results from the executed program


I have  a program that displays the current running processes to the screen. I need to have a program execute that display program and capture the results to a file. The display program does pause at the bottom of each page waiting for an 'enter' to go to the next page.

Note( the display program will not successfully compile on the current system but it does work)

Also - very, very new to Mumps. 



Discussion (23)0
Log in or sign up to continue

@Sourabh Sethi gives you reasonable advice.  You have a code which displays something on a terminal.

If display is done with "write" command (but not with some device-specific video-memory related commands) you can switch the device before calling the "program" and it will direct all the "writes" into the file. 

But maybe "your program" changes the device to terminal intentionally in the code - so I think you cannot go with USE device approach in this case - better change the code. You say "you cannot compile the program" - but do you have the source code to see what it really does? If yes you can easily answer yourself what it does and operate accordingly. 

Maybe another idea is to change the device "terminal" in your system - maybe you can log everything from the device to a file. I don't remember if we have this feature for device settings.

Hello Bob,

I believe something similar to the following is what others have been suggesting.

open file:("WNS"):3
if ('$test) {  write !,"Failed to open "_file  quit  }
use file
do ALL^%SS
close file

This works for me.  Is this what you did?  Is it not working for you?

Note that, unlike my minimal example, your code should of course include proper error trapping/handling.

Hope that helps,