web stats
Run pscp.exe via javascript - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-26-2016, 07:46 AM
themochael themochael is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Posts: 54
themochael is on a distinguished road
Default Run pscp.exe via javascript

I have a batch script that is run via a javascript reader. It runs, but nothing happens. I can run the batch manually and it works fine. Am i missing something?


logger.error("running batch file: D:\\FILES\\move.bat");

var pr = java.lang.Runtime.getRuntime().exec("D:\\FILES\\mo ve_manual.bat");
var thread = new java.lang.Thread(new java.lang.Runnable({run:function(){while(pr.getInp utStream().read()!=-1);}}));
thread.start();
while(pr.getErrorStream().read() != -1);
thread.join();
pr.waitFor();

logger.error("Batch File Ran");

Last edited by themochael; 04-26-2016 at 11:29 AM.
Reply With Quote
  #2  
Old 04-26-2016, 11:30 AM
themochael themochael is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Posts: 54
themochael is on a distinguished road
Default

Updated question and adding the channel
Attached Files
File Type: xml MOVE_BATCH.xml (22.0 KB, 4 views)
Reply With Quote
  #3  
Old 09-16-2016, 10:53 AM
jg12345 jg12345 is offline
OBX.3 Kenobi
 
Join Date: Oct 2012
Posts: 105
jg12345 is on a distinguished road
Default

I have the same problem. The Windows batch file runs but does not complete the job. It works fine when running it manually from within Windows.
Reply With Quote
  #4  
Old 09-16-2016, 10:54 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

Try this instead: http://www.mirthcorp.com/community/f...7649#post47649
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #5  
Old 09-16-2016, 11:46 AM
jg12345 jg12345 is offline
OBX.3 Kenobi
 
Join Date: Oct 2012
Posts: 105
jg12345 is on a distinguished road
Default

Hi Nick,

I added the executeRuntimeCommand function in a code template, but not sure how to call my file. What would I change below if I want to run this file? c:\mirth_test\test.bat

var result = executeRuntimeCommand('tail /var/log/messages');

logger.info('Exit value: ' + result.exitValue);
logger.info('Output: ' + result.stdout);
if (result.stderr != '') {
logger.error('Errors: ' + result.stderr);
}
Reply With Quote
Reply

Tags
file reader, javascript

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 02:56 AM.


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