Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using the following code to make an SSH connection and download a file to the SSH server through curl. It gives me an exception without a message. Not really sure what to do at this point.

try{
      JSch jsch=new JSch(); 
      String host=selectedItem.getHost();
      String user="down2home";
      int port = selectedItem.getPort();
      String password = selectedItem.getPass();
      String dlurl = dlurlField.getText().toString();

      Session session=jsch.getSession(user, host, port);
      session.setPassword(password);
      UserInfo ui = new MyUserInfo(){
      };
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      String command = "curl -L --create-dirs -o /home/paul/Desktop/geeknights/geeknights.mp3 "+dlurl+"\r\n";
      out.write(command.getBytes());
      out.flush();
      InputStream in = new ByteArrayInputStream(out.toByteArray());
      session.setUserInfo(ui);
      session.connect(30*1000);   // making a connection with timeout.
      Channel channel=session.openChannel("shell");
      channel.setInputStream(in);
      channel.setOutputStream(System.out);
      channel.connect(3*1000);
    }
    catch(Exception e){
        String errorMessage = (e.getMessage()==null)?"Message is empty":e.getMessage();
        Log.e("Exception:", errorMessage );  
    }

Traceback:

06-08 00:33:16.561: E/Exception:(9293): Message is empty
share|improve this question
    
You need to log and post the stack trace here. –  EJP Jun 8 '13 at 8:47
    
Thanks. I figured out it was a NetworkOnMainThreadException. –  sajattack Jun 8 '13 at 22:02

1 Answer 1

up vote 0 down vote accepted

Turned out to be a NetworkOnMainThreadException. Not sure why it wouldn't give me that message with e.getMessage()

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.