public void runCommand(String command) throws Exception {
        String result = "";
        String extras = "export PYTHONWARNINGS=\"ignore:Unverified HTTPS request\" && ";

        Channel channel = session.openChannel("exec");
        ((ChannelExec) channel).setCommand(extras + command);

        channel.setInputStream(null);
        ((ChannelExec) channel).setErrStream(System.err);

        InputStream in = channel.getInputStream();

        ((ChannelExec) channel).setPty(true);

        channel.connect();

        byte[] tmp = new byte[1024];
        while (true) {
            while (in.available() > 0) {
                int i = in.read(tmp, 0, 1024);
                if (i < 0) {
                    break;
                }
                result = result + new String(tmp, 0, i);
            }
            this.result = result;
            this.setResult(result);

            if (channel.isClosed()) {
                if (in.available() > 0) {
                    continue;
                }
                this.exitStatus = channel.getExitStatus();
                break;
            }
            try {
                Thread.sleep(1000);
            } catch (Exception ee) {
            }
        }

        channel.disconnect();
    }
public void runCommand ( String command ) throws Exception { String result = "" ; String extras = "export PYTHONWARNINGS=\"ignore:Unverified HTTPS request\" && " ; Channel channel = session . openChannel ( "exec" ) ; ( ( ChannelExec ) channel ) . setCommand ( extras + command ) ; channel . setInputStream ( null ) ; ( ( ChannelExec ) channel ) . setErrStream ( System . err ) ; InputStream in = channel . getInputStream ( ) ; ( ( ChannelExec ) channel ) . setPty ( true ) ; channel . connect ( ) ; byte [ ] tmp = new byte [ 1024 ] ; while ( true ) { while ( in . available ( ) > 0 ) { int i = in . read ( tmp , 0 , 1024 ) ; if ( i < 0 ) { break ; } result = result + new String ( tmp , 0 , i ) ; } this . result = result ; this . setResult ( result ) ; if ( channel . isClosed ( ) ) { if ( in . available ( ) > 0 ) { continue ; } this . exitStatus = channel . getExitStatus ( ) ; break ; } try { Thread . sleep ( 1000 ) ; } catch ( Exception ee ) { } } channel . disconnect ( ) ; }
Execute the command in the session created

@param command