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

Hi,

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. 

Thanks,

Bob

  • 0
  • 0
  • 184
  • 20
  • 3

Respuestas

Hi,

To run do cmd^zpipe(), do I need to put the code provided into a program and compile it?

Then when I run it replace cmd with the program that I wish to test?

In my case it would be  D SS^ZPIPE() OR  D ^%SS^SPIPE()

I really am new to this. I have access to the free online documentation and some cache programs.

Bob

Sorry, this is a description of how to run a program of WINDOWS or LINUX from Caché.

What you address here ar Caché Routines or ClassMethods. 

Create a wrapper, which will OPEN a FILE, and USE it.

Then call your program from the wrapper.

Then close ur file.

I guess this should force to write in file if the earlier program is writing in terminal.

Hi,

JOBEXAM? never heard of it.

The program is a MUMPS program. The results display on the screen. I need a program to execute that program to capture the result, write it to a file and email that file. A cron will run it every 15 minutes.

Thanks,

Bob

Hello,

I looked up JOBEXAM. That might display what I need but, I need to be able to capture the result into a file and email that file every 15 minutes. So  if I use the program that I have or JOBEXAM, I still need a way to get the results into a file that I can email.

Thanks for your patience,

Bob

Hi,

I think that I am closer.

I created a wrapper. I opened a file, executed the SS program, closed and emailed the file.

But, The program displayed the results to the screen and created a zero byte file that it emailed.

How can I get the output to not display and get written to the open file?

Thanks,

Bob

Hi, 

Yes, I think so.

I opened the file (file-name)  then I did USE file-name.

It displayed to the terminal and created an empty file.

Bob

@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
quit

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,

Aaron

Hi,

Yes, my code does have all of the necessary error handling.

I did not have the ALL in the D statement. I added it with no space before the ^.

It compiled and ran. It did stop the program from prompting between pages but I still have an empty file.

Bob

Hey Bob,

Sorry for delay in response as I was not working today.

Can you please share the code of wrapper you have written.

USE command should share the device.

Regards

Sourabh

Hi,

Thanks for your response.

Robert Cemper sent me the solution.

use file do ALL^%SS      ;; must be the same line

Worked perfectly.

Bob

if you test your example from terminal prompt it needs some important change:

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

Hi,

OMG!. Too cool. That worked.

Thank you very, very much.

Bob

Comentarios

Hi Bob!

Could you please share the version of InterSystems Data platform you execute the program in? Is it Caché, or Ensemble or InterSystems IRIS?

Also, what is the OS as a host?

Hi,

Is this something that just can't be done in mumps/cache?

Thanks,
Bob