Class JschSession.JschProcess

  • Enclosing class:
    JschSession

    private class JschSession.JschProcess
    extends java.lang.Process
    Implementation of Process for running a single command using Jsch.

    Uses the Jsch session to do actual command execution and manage the execution.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.jcraft.jsch.ChannelExec channel  
      private java.io.InputStream errStream  
      private java.io.InputStream inputStream  
      private java.io.OutputStream outputStream  
      (package private) int timeout  
    • Constructor Summary

      Constructors 
      Constructor Description
      JschProcess​(java.lang.String commandName, java.util.Map<java.lang.String,​java.lang.String> environment, int tms)
      Opens a channel on the session ("sock") for executing the given command, opens streams, and starts command execution.
    • Field Detail

      • channel

        private com.jcraft.jsch.ChannelExec channel
      • timeout

        final int timeout
      • inputStream

        private java.io.InputStream inputStream
      • outputStream

        private java.io.OutputStream outputStream
      • errStream

        private java.io.InputStream errStream
    • Constructor Detail

      • JschProcess

        JschProcess​(java.lang.String commandName,
                    java.util.Map<java.lang.String,​java.lang.String> environment,
                    int tms)
             throws TransportException,
                    java.io.IOException
        Opens a channel on the session ("sock") for executing the given command, opens streams, and starts command execution.
        Parameters:
        commandName - the command to execute
        environment - environment variables to pass on
        tms - the timeout value, in seconds, for the command.
        Throws:
        TransportException - on problems opening a channel or connecting to the remote host
        java.io.IOException - on problems opening streams
    • Method Detail

      • closeOutputStream

        private void closeOutputStream()
      • setupStreams

        private void setupStreams()
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • getInputStream

        public java.io.InputStream getInputStream()
        Specified by:
        getInputStream in class java.lang.Process
      • getOutputStream

        public java.io.OutputStream getOutputStream()
        Specified by:
        getOutputStream in class java.lang.Process
      • getErrorStream

        public java.io.InputStream getErrorStream()
        Specified by:
        getErrorStream in class java.lang.Process
      • exitValue

        public int exitValue()
        Specified by:
        exitValue in class java.lang.Process
      • isRunning

        private boolean isRunning()
      • destroy

        public void destroy()
        Specified by:
        destroy in class java.lang.Process
      • waitFor

        public int waitFor()
                    throws java.lang.InterruptedException
        Specified by:
        waitFor in class java.lang.Process
        Throws:
        java.lang.InterruptedException