I'm calling jsch in our Mirth interface engine to copy files from our local directory to a remote sftp directory, I want to remove file from local directory after Channel.put has place the file on the remote server directory. Here is my initial code for putting files using javascript code to call jsch in Mirth. Files get to remote directory with no problem.
importPackage(com.jcraft.jsch);
var jsch = new JSch();
jsch.addIdentity("C:\\Directory\\test.key", "test");
jsch.setConfig('StrictHostKeyChecking','no');
var session = jsch.getSession('UserName','datatrans.test.se',22);
session.setTimeout(20000);
//session.setPassword('password');
session.connect();
var channel = session.openChannel('sftp');
channel.connect();
logger.debug('Connected to Biosense SFTP');
var filename = '\\' + $('originalFilename');
logger.debug(filename);
channel.put('D:\\Directory\\*.hl7', filename);
logger.debug('Place files in directory ' + filename);
channel.exit();
logger.debug('exit sftp dir');
session.disconnect();
logger.debug('session completed!');