web stats
Calling system command from Mirth - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-28-2014, 05:03 PM
rohit.chawla12 rohit.chawla12 is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Location: Australia
Posts: 72
rohit.chawla12 is on a distinguished road
Smile Calling system command from Mirth

Hi Guys,
I am using Mirth3.0. I am having a requirement to check the database lock before performing any operations on the database through mirth. This can only be achieved by the system command. How I can get the system command results in mirth. As of now, I have tried the following:
var proc=java.lang.Runtime.getRuntime().exec("ls"); //say ls is command to know the database lock status
logger.debug(proc);
var stdin = proc.getInputStream();
logger.debug(stdin);
var isr = new InputStreamReader(stdin);
logger.debug(isr);
var br = new BufferedReader(isr);
var temp=br.readLine();
logger.debug(temp);

From all of the loggers above I am getting the object values like for example:
java.lang.UNIXProcess@3fd49dca
java.lang.UNIXProcess$ProcessPipeInputStream@1c1b4 5b4
etc
Reply With Quote
  #2  
Old 10-28-2014, 05:57 PM
rohit.chawla12 rohit.chawla12 is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Location: Australia
Posts: 72
rohit.chawla12 is on a distinguished road
Smile Calling system command from Mirth

Hi Guys,
I have found the solution. Earlier, I was missing to specify the complete path of the java classes in use.
Below is the running code

debug='ON';
var proc=java.lang.Runtime.getRuntime().exec("ls -ltr");
proc.waitFor();
var bufferReader=new java.io.BufferedReader(new java.io.InputStreamReader(proc.getInputStream()));
var line;

while ((line = bufferReader.readLine()) != null) {
logger.debug(line);
}
bufferReader.close();
Reply With Quote
Reply

Tags
mirth, mirth 3.0, mirth 3.0 api

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 05:07 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation