I'm trying to run commands via JSch. I can run standard commands such as ls
. But if I need to run our commands let's say abc <param>
it reruns me
ksh: abc: not found
I tried to use ((ChannelExec)channel).setPty(true);
, but it still wouldn't work.
My channel set up looks like this:
Channel channel=session.openChannel("exec");
((ChannelExec)channel).setPty(true);
((ChannelExec)channel).setCommand(fullCommand);
channel.setInputStream(null);
((ChannelExec)channel).setErrStream(System.err);
InputStream in=channel.getInputStream();
channel.connect();
byte[] tmp=new byte[1024];
while(true){
while(in.available()>0){
int i=in.read(tmp, 0, 1024);
if(i<0)break;
System.out.print(new String(tmp, 0, i));
}
if(channel.isClosed()){
System.out.println("exit-status: "+channel.getExitStatus());
break;
}
try{Thread.sleep(1000);}catch(Exception ee){}
}
How can I make my custom commands and aliases work with JSch?