我无法在ssh中执行以下命令获取错误使用错误,而我能够手动执行代码则为
public static void main(String[] args) {
String host="";
String user="";
String password="";
//String command1="mml";
String command2="mml hgsdp:msisdn=919051018408";
try{
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
JSch jsch = new JSch();
Session session=jsch.getSession(user, host, 22);
session.setPassword(password);
session.setConfig(config);
session.connect();
System.out.println("Connected");
Channel channel=session.openChannel("exec");
//((ChannelExec)channel).setCommand(command1);
((ChannelExec)channel).setCommand(command2);
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){}
}
channel.disconnect();
session.disconnect();
System.out.println("DONE");
}catch(Exception e){
e.printStackTrace();
}
}
答案 0 :(得分:0)
错误是由MML仅使用Telnet引起的,这是根据MML文档。