Results 1 to 2 of 2
  1. #1
    abi3719 is offline Member
    Join Date
    Sep 2010
    Rep Power

    Default JSCh Connectivity Problem


    I use JSCh jar file, to connect to remote unix host and execute commands. But, the following code snippet has a problem :

    session = jsch.getSession(user,host_name,22);
    System.out.println("Session created");
    UserInfo usrInfo=new MyUserInfo();
    Channel channel=session.openChannel("exec");
    ((ChannelExec) channel).setCommand(cmd);
    InputStream in;
    in = channel.getInputStream();
    System.out.println("Input stream is:"+channel.getInputStream());
    System.out.println("Channel Initiated");
    System.out.println("Channel set io stream done successfully");
    byte[] tmp = new byte[1024];
    while (true)
    while (in.available() > 0)
    System.out.println("I enter this while");
    int i =, 0, 1024);
    if (i < 0)
    s = new String(tmp, 0, i);
    System.out.print("The String returned is: "+s);

    This code snippet works, when i debug it. But, when i run the same, it doesnt run as expected. I found out, the problem is with the channel. The channel gets closed unexpectedly, and thats why the 'while' loop (in bold), doesnt gets executed. Kindly help.Thanks.

  2. #2
    s2sgateway is offline Member
    Join Date
    Sep 2010
    Rep Power

Similar Threads

  1. problem in sql connectivity
    By Bharati in forum JDBC
    Replies: 3
    Last Post: 03-26-2010, 07:50 PM
  2. Replies: 5
    Last Post: 01-28-2010, 01:34 PM
  3. JSch 0.1.38
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 04-24-2008, 07:50 PM
  4. JSch 0.1.36
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 10-30-2007, 07:05 PM
  5. JSch 0.1.33
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-11-2007, 10:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts