cant see output of ssh command

Help
Anonymous
2011-06-13
2013-05-28

  • Anonymous
    2011-06-13

    Hi,
    I'm using jsch with android. 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;
                    }
            }