Logo Search packages:      
Sourcecode: jenkins-trilead-ssh2 version File versions  Download package

int com::trilead::ssh2::Connection::exec ( String  command,
OutputStream  output 
) throws IOException, InterruptedException [inline]

Executes a process remotely and blocks until its completion.

Parameters:
outputThe stdout/stderr will be sent to this stream.

Definition at line 1433 of file Connection.java.

References com::trilead::ssh2::Session::close(), com::trilead::ssh2::Session::execCommand(), com::trilead::ssh2::ChannelCondition::EXIT_STATUS, com::trilead::ssh2::Session::getExitStatus(), openSession(), and com::trilead::ssh2::Session::waitForCondition().

                                                                                                  {
        Session session = openSession();
        try {
            session.execCommand(command);
            PumpThread t1 = new PumpThread(session.getStdout(), output);
            t1.start();
            PumpThread t2 = new PumpThread(session.getStderr(), output);
            t2.start();
            session.getStdin().close();
            t1.join();
            t2.join();

            // wait for some time since the delivery of the exit status often gets delayed
            session.waitForCondition(ChannelCondition.EXIT_STATUS,3000);
            Integer r = session.getExitStatus();
            if(r!=null) return r.intValue();
            return -1;
        } finally {
            session.close();
        }
    }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index