You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Penza Kenneth at MITA <ke...@gov.mt> on 2014/07/10 14:36:48 UTC

ssh java client

Hi,

I am using MINA Java SSH client to execute a set of commands on a Linux server. The library I am using is built from source as I wanted to use the async interfaces (so that I can above the client blocking for IO). The client is working fine. However I want to implement a timeout within which the command must return. Is this functionality implemented in the MINA SSH library ?


Thanks for your help
Kenneth

RE: ssh java client

Posted by Penza Kenneth at MITA <ke...@gov.mt>.
I have used the syntax mentioned below and it worked fine. Thanks alot for your help.

Kenneth

-----Original Message-----
From: Guillaume Nodet [mailto:gnodet@apache.org] 
Sent: Thursday, 10 July 2014 14:56
To: dev@mina.apache.org
Subject: Re: ssh java client

You could try something like the following:

        ChannelExec channel = session.createExecChannel("the command to execute");
        channel.setOut(new NoCloseOutputStream(System.out));
        channel.setErr(new NoCloseOutputStream(System.err));
        channel.open().await();
        // send any data if you need
        if ((channel.waitFor(ChannelExec.CLOSED, timeoutInMillis) &
ChannelExec.CLOSED) == 0) {
             // this is a timeout
        }



2014-07-10 14:36 GMT+02:00 Penza Kenneth at MITA <ke...@gov.mt>:

> Hi,
>
> I am using MINA Java SSH client to execute a set of commands on a 
> Linux server. The library I am using is built from source as I wanted 
> to use the async interfaces (so that I can above the client blocking 
> for IO). The client is working fine. However I want to implement a 
> timeout within which the command must return. Is this functionality 
> implemented in the MINA SSH library ?
>
>
> Thanks for your help
> Kenneth
>

Re: ssh java client

Posted by Guillaume Nodet <gn...@apache.org>.
You could try something like the following:

        ChannelExec channel = session.createExecChannel("the command to
execute");
        channel.setOut(new NoCloseOutputStream(System.out));
        channel.setErr(new NoCloseOutputStream(System.err));
        channel.open().await();
        // send any data if you need
        if ((channel.waitFor(ChannelExec.CLOSED, timeoutInMillis) &
ChannelExec.CLOSED) == 0) {
             // this is a timeout
        }



2014-07-10 14:36 GMT+02:00 Penza Kenneth at MITA <ke...@gov.mt>:

> Hi,
>
> I am using MINA Java SSH client to execute a set of commands on a Linux
> server. The library I am using is built from source as I wanted to use the
> async interfaces (so that I can above the client blocking for IO). The
> client is working fine. However I want to implement a timeout within which
> the command must return. Is this functionality implemented in the MINA SSH
> library ?
>
>
> Thanks for your help
> Kenneth
>