I am using ssh to execute Sqoop commands. This is the reference for my code How to use Sqoop in Java Program?
But I'm getting an error as "sqoop command not found". This is the code
package sqoop;
import net.neoremind.sshxcute.core.Result;
import net.neoremind.sshxcute.core.SSHExec;
import net.neoremind.sshxcute.core.ConnBean;
import net.neoremind.sshxcute.task.CustomTask;
import net.neoremind.sshxcute.task.impl.ExecCommand;
public class TestSSH {
public static void main(String args[]) throws Exception{
ConnBean cb = new ConnBean("172.17.13.47", "miracle","miracle");
SSHExec ssh = SSHExec.getInstance(cb);
ssh.connect();
CustomTask sampleTask2 = new ExecCommand("sqoop import --connect jdbc:oracle:thin:@172.17.13.47:1521/xe --username ouser --password oracleuser --table BRANCH --target-dir /user/branch -m 1");
Result res = ssh.exec(sampleTask2);
if (res.isSuccess)
{
System.out.println("Return code: " + res.rc);
System.out.println("sysout: " + res.sysout);
}
else
{
System.out.println("Return code: " + res.rc);
System.out.println("error message: " + res.error_msg);
}
ssh.disconnect();
}
}
The error it shows is : "Execution failed while executing command: Error message: bash: sqoop: command not found" I have added the sshxcute jar file too.
But when I try that Sqoop command on terminal, it works perfectly. Please let me know how I can achieve this. Thanks.