Hi
I need to execute few Shell Scripts which live at a remote machine. As of now, am using a third party library (JSch). I just got introduced to Shell-Task. Can I use this to connect to a remote host and then execute the script there by passing some arguments ?
As of now , the code in my Service-Task class looks like this : -
JSch jsch=new JSch();
jsch.addIdentity("/root/.ssh/id_rsa"); // Private Key path, so that password is not needed
Session session=jsch.getSession(userName,"HostName");
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
Channel channel = session.openChannel("exec");
ChannelExec channelExe = (ChannelExec) channel;
channelExe.setCommand(scriptPath+arguments);