public ChannelExec getExecChannel ( String command ) throws SftpException { ChannelExec channelExec ; try { channelExec = ( ChannelExec ) this . session . openChannel ( "exec" ) ; channelExec . setCommand ( command ) ; channelExec . connect ( ) ; return channelExec ; } catch ( JSchException e ) { throw new SftpException ( 0 , "Cannot open a channel to SFTP server" , e ) ; } }
Create a new sftp channel to execute commands .