Sunday, June 12, 2011

[android-developers] can't see output of ssh command

Hi,
I'm using jsch to execute a command and then shows me the output of
the command, but I cant see the ouput of command with LogCat. Could
you help me please? Many thanks and sorry for my english!

public String texto (String comando){

Log.d("PRUEBA", "CONSULTA CRON DENTRO DEL OBJETO");
String username = "xxxxxxxx";
String password = "yyyyyyyyy";
JSch jsch = new JSch();
Session session;
try {
session = jsch.getSession(username, "xx.yy.zz.aa", 22);
session.setPassword(password);

// Avoid asking for key confirmation
Properties prop = new Properties();
prop.put("StrictHostKeyChecking", "no");
session.setConfig(prop);

session.connect();

// SSH Channel
ChannelExec channelssh = (ChannelExec)
session.openChannel("exec");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
channelssh.setOutputStream(baos);

// Execute command
channelssh.setCommand("ls");
channelssh.connect();
channelssh.disconnect();
Log.d("PRUEBA","BIEN");
Log.d("PRUEBA","RESULADO ------" + baos.toString());
return baos.toString();

} catch (JSchException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("PRUEBA","ERROR");
return null;
}

}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate