import java.util.HashMap; import java.util.Properties; import net.neoremind.sshxcute.core.ConnBean; import net.neoremind.sshxcute.core.Result; import net.neoremind.sshxcute.core.SSHExec; import net.neoremind.sshxcute.exception.TaskExecFailException; import net.neoremind.sshxcute.task.CustomTask; import net.neoremind.sshxcute.task.impl.ExecCommand; public class UnixConnect { // String hostName, String logFile, String userName, String password static String[] host_names = null; static String[] user_names = null; static String[] pwd_text = null; public void execCommand() throws TaskExecFailException { ConnBean cb1 = new ConnBean("0.000.00.000", "***", "****"); SSHExec ssh1 = SSHExec.getInstance(cb1); ssh1.connect(); String[] cmd = {"cd /apps/a/b/c/logs","tail -1 aLoadJob.log"}; CustomTask tasks = new ExecCommand(cmd); Result res1 = ssh1.exec(tasks); if (res1.isSuccess) { /*System.out.println(res1.sysout)*/; } else { System.out.println("Return code: " + res1.sysout); System.out.println("error message: " + res1.error_msg); } ssh1.disconnect(); } /** * @param args */ public static void main(String[] args) throws TaskExecFailException { UnixConnect ob = new UnixConnect(); ob.execCommand(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)