unable to execute a .sh script with Jsch
i'm trying to execute a script shell in a unix server from my java application (on my windows seven station) using the ssh api Jsch.
the script shell i'm using "start_lm" is a C binary.
this is the code i'm using (it's from the Jsch website exemples)
try{
JSch jsch=new JSch();
Session session=jsch.getSession(user, host, 22);
UserInfo ui=new MyUserInfo();
session.setUserInfo(ui);
session.connect();
String command="user/psi/start_lm";
Channel channel=ses开发者_运维问答sion.openChannel("exec");
((ChannelExec)channel).setCommand(command);
channel.setInputStream(null);
((ChannelExec)channel).setErrStream(System.err);
InputStream in=channel.getInputStream();
channel.connect();
while(true){
if(channel.isClosed()){
System.out.println("exit-status: "+channel.getExitStatus());
break;
}
try{Thread.sleep(1000);}catch(Exception ee){}
}
channel.disconnect();
session.disconnect();
}
the error i'm getting is
exit-status: -1 what does it mean
thanks for ure help.
There's the problem I believe
". ./start_lm.sh
It should be below provided script present in current directory
"./start_lm.sh
as exit status 127
says
127 "command not found" illegal_command
String command="/bin/sh /user/psi/start_lm.sh";
Please try the above, for jsch might be using an non-interactive shell.
精彩评论