# SessionChannel (sshj 0.4.0 API)
Date: 2011-06-06

## net.schmizz.sshj.connection.channel.direct
Class SessionChannel

    java.lang.Object
      net.schmizz.sshj.connection.channel.AbstractChannel
          net.schmizz.sshj.connection.channel.direct.AbstractDirectChannel
              net.schmizz.sshj.connection.channel.direct.SessionChannel

All Implemented Interfaces:
  Closeable, ErrorNotifiable, SSHPacketHandler, Channel, Channel.Direct, Session, Session.Command, Session.Shell, Session.Subsystem

    public class SessionChannel

extends AbstractDirectChannel
implements Session, Session.Command, Session.Shell, Session.Subsystem

`Session` implementation.

Nested Class Summary

Nested classes/interfaces inherited from interface net.schmizz.sshj.connection.channel.direct.Session
`Session.Command, Session.Shell, Session.Subsystem`

Nested classes/interfaces inherited from interface net.schmizz.sshj.connection.channel.Channel
`Channel.Direct, Channel.Forwarded`

Nested classes/interfaces inherited from interface net.schmizz.sshj.common.ErrorNotifiable
`ErrorNotifiable.Util`

Field Summary

Fields inherited from class net.schmizz.sshj.connection.channel.AbstractChannel
`close, conn, log, lwin, open, rwin, trans`

Constructor Summary
`SessionChannel(Connection conn)`

Method Summary
`void` `allocateDefaultPTY()` Allocates a default PTY.
`void` `allocatePTY(String term, int cols, int rows, int width, int height, Map<PTYMode,Integer> modes)` Allocate a psuedo-terminal for this session.
`Boolean` `canDoFlowControl()` Whether the client can do local flow control using `control-S` and `control-Q`.
`void` `changeWindowDimensions(int cols, int rows, int width, int height)` Sends a window dimension change message.
`protected void` `closeAllStreams()` Called when all I/O streams should be closed.
`protected void` `eofInputStreams()` Called when EOF has been received.
`Session.Command` `exec(String command)` Execute a remote command.
`String` `getErrorAsString()` Deprecated.
`InputStream` `getErrorStream()` Returns the command's `stderr` stream.
`String` `getExitErrorMessage()` If the command exit violently `with a signal`, an error message would have been received and can be retrieved via this method.
`Signal` `getExitSignal()` Returns the `signal` if the command exit violently, or `null` if this information was not received.
`Integer` `getExitStatus()` Returns the exit status of the command if it was received, or `null` if this information was not received.
`Boolean` `getExitWasCoreDumped()` If the command exit violently `with a signal`, information about whether a core dump took place would have been received and can be retrieved via this method.
`String` `getOutputAsString()` Deprecated.
`protected void` `gotExtendedData(SSHPacket buf)`
`void` `handleRequest(String req, SSHPacket buf)`
`void` `notifyError(SSHException error)` Notifies this object of an `error`.
`void` `reqX11Forwarding(String authProto, String authCookie, int screen)` Request X11 forwarding.
`void` `setEnvVar(String name, String value)` Set an enviornment variable.
`void` `signal(Signal sig)` Send a signal to the remote command.
`Session.Shell` `startShell()` Request a shell.
`Session.Subsystem` `startSubsystem(String name)` Request a subsystem.

Methods inherited from class net.schmizz.sshj.connection.channel.direct.AbstractDirectChannel
`buildOpenReq, gotUnknown, open`

Methods inherited from class net.schmizz.sshj.connection.channel.AbstractChannel
`close, finishOff, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getOutputStream, getRecipient, getRemoteMaxPacketSize, getRemoteWinSize, getType, handle, init, isOpen, join, join, newBuffer, receiveInto, sendChannelRequest, sendClose, sendEOF, setAutoExpand, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface net.schmizz.sshj.connection.channel.Channel
`close, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getOutputStream, getRecipient, getRemoteMaxPacketSize, getRemoteWinSize, getType, isOpen, join, join, sendEOF, setAutoExpand`

Methods inherited from interface net.schmizz.sshj.common.SSHPacketHandler
`handle`

Constructor Detail

### SessionChannel

    public SessionChannel(Connection conn)

Method Detail

### allocateDefaultPTY

    public void allocateDefaultPTY()
                            throws ConnectionException,
                                   TransportException

  Description copied from interface: `Session`
  Allocates a default PTY. The default PTY is `"vt100"` with the echo modes disabled.

  Specified by:
    `allocateDefaultPTY` in interface `Session`
  Throws:
    `ConnectionException`
    `TransportException`

### allocatePTY

    public void allocatePTY(String term,
                            int cols,
                            int rows,
                            int width,
                            int height,
                            Map<PTYMode,Integer> modes)
                     throws ConnectionException,
                            TransportException

  Description copied from interface: `Session`
  Allocate a psuedo-terminal for this session.

  `0` dimension parameters will be ignored by the server.

  Specified by:
    `allocatePTY` in interface `Session`
  Parameters:
    `term` - `TERM` environment variable value (e.g., `vt100`)
    `cols` - terminal width, cols (e.g., 80)
    `rows` - terminal height, rows (e.g., 24)
    `width` - terminal width, pixels (e.g., 640)
    `height` - terminal height, pixels (e.g., 480)
  Throws:
    `ConnectionException`
    `TransportException`

### canDoFlowControl

    public Boolean canDoFlowControl()

  Description copied from interface: `Session.Shell`
  Whether the client can do local flow control using `control-S` and `control-Q`.

  Specified by:
    `canDoFlowControl` in interface `Session.Shell`
  Returns:
    boolean value indicating whether 'client can do', or `null` if no such information was received

### changeWindowDimensions

    public void changeWindowDimensions(int cols,
                                       int rows,
                                       int width,
                                       int height)
                                throws TransportException

  Description copied from interface: `Session.Shell`
  Sends a window dimension change message.

  Specified by:
    `changeWindowDimensions` in interface `Session.Shell`
  Parameters:
    `cols` - terminal width, columns
    `rows` - terminal height, rows
    `width` - terminal width, pixels
    `height` - terminal height, pixels
  Throws:
    `TransportException`

### exec

    public Session.Command exec(String command)
                         throws ConnectionException,
                                TransportException

  Description copied from interface: `Session`
  Execute a remote command.

  Specified by:
    `exec` in interface `Session`
  Returns:
    `Session.Command` instance which should now be used
  Throws:
    `ConnectionException` - if the request to execute the command failed
    `TransportException` - if there is an error sending the request

### getErrorStream

    public InputStream getErrorStream()

  Description copied from interface: `Session.Command`
  Returns the command's `stderr` stream.

  Specified by:
    `getErrorStream` in interface `Session.Command`
  Specified by:
    `getErrorStream` in interface `Session.Shell`

### getExitErrorMessage

    public String getExitErrorMessage()

  Description copied from interface: `Session.Command`
  If the command exit violently `with a signal`, an error message would have been received and can be retrieved via this method. Otherwise, this method will return `null`.

  Specified by:
    `getExitErrorMessage` in interface `Session.Command`

### getExitSignal

    public Signal getExitSignal()

  Description copied from interface: `Session.Command`
  Returns the `signal` if the command exit violently, or `null` if this information was not received.

  Specified by:
    `getExitSignal` in interface `Session.Command`

### getExitStatus

    public Integer getExitStatus()

  Description copied from interface: `Session.Command`
  Returns the exit status of the command if it was received, or `null` if this information was not received.

  Specified by:
    `getExitStatus` in interface `Session.Command`
  Specified by:
    `getExitStatus` in interface `Session.Subsystem`

### handleRequest

    public void handleRequest(String req,
                              SSHPacket buf)
                       throws ConnectionException,
                              TransportException

  Overrides:
    `handleRequest` in class `AbstractChannel`
  Throws:
    `ConnectionException`
    `TransportException`

### reqX11Forwarding

    public void reqX11Forwarding(String authProto,
                                 String authCookie,
                                 int screen)
                          throws ConnectionException,
                                 TransportException

  Description copied from interface: `Session`
  Request X11 forwarding.

  Specified by:
    `reqX11Forwarding` in interface `Session`
  Parameters:
    `authProto` - X11 authentication protocol name
    `authCookie` - X11 authentication cookie
    `screen` - X11 screen number
  Throws:
    `ConnectionException` - if the request failed
    `TransportException` - if there was an error sending the request

### setEnvVar

    public void setEnvVar(String name,
                          String value)
                   throws ConnectionException,
                          TransportException

  Description copied from interface: `Session`
  Set an enviornment variable.

  Specified by:
    `setEnvVar` in interface `Session`
  Parameters:
    `name` - name of the variable
    `value` - value to set
  Throws:
    `ConnectionException` - if the request failed
    `TransportException` - if there was an error sending the request

### signal

    public void signal(Signal sig)
                throws TransportException

  Description copied from interface: `Session.Command`
  Send a signal to the remote command.

  Specified by:
    `signal` in interface `Session.Command`
  Specified by:
    `signal` in interface `Session.Shell`
  Parameters:
    `sig` - the signal
  Throws:
    `TransportException` - if error sending the signal

### startShell

    public Session.Shell startShell()
                             throws ConnectionException,
                                    TransportException

  Description copied from interface: `Session`
  Request a shell.

  Specified by:
    `startShell` in interface `Session`
  Returns:
    `Session.Shell` instance which should now be used
  Throws:
    `ConnectionException` - if the request failed
    `TransportException` - if there was an error sending the request

### startSubsystem

    public Session.Subsystem startSubsystem(String name)
                                     throws ConnectionException,
                                            TransportException

  Description copied from interface: `Session`
  Request a subsystem.

  Specified by:
    `startSubsystem` in interface `Session`
  Parameters:
    `name` - subsystem name
  Returns:
    `Session.Subsystem` instance which should now be used
  Throws:
    `ConnectionException` - if the request failed
    `TransportException` - if there was an error sending the request

### getExitWasCoreDumped

    public Boolean getExitWasCoreDumped()

  Description copied from interface: `Session.Command`
  If the command exit violently `with a signal`, information about whether a core dump took place would have been received and can be retrieved via this method. Otherwise, this method will return `null`.

  Specified by:
    `getExitWasCoreDumped` in interface `Session.Command`

### closeAllStreams

    protected void closeAllStreams()

  Description copied from class: `AbstractChannel`
  Called when all I/O streams should be closed. Subclasses can override but must call super.

  Overrides:
    `closeAllStreams` in class `AbstractChannel`

### eofInputStreams

    protected void eofInputStreams()

  Description copied from class: `AbstractChannel`
  Called when EOF has been received. Subclasses can override but must call super.

  Overrides:
    `eofInputStreams` in class `AbstractChannel`

### gotExtendedData

    protected void gotExtendedData(SSHPacket buf)
                            throws ConnectionException,
                                   TransportException

  Overrides:
    `gotExtendedData` in class `AbstractChannel`
  Throws:
    `ConnectionException`
    `TransportException`

### notifyError

    public void notifyError(SSHException error)

  Description copied from interface: `ErrorNotifiable`
  Notifies this object of an `error`.

  Specified by:
    `notifyError` in interface `ErrorNotifiable`
  Overrides:
    `notifyError` in class `AbstractChannel`

### getOutputAsString

    @Deprecated
    public String getOutputAsString()
                             throws IOException

  Deprecated.

  Specified by:
    `getOutputAsString` in interface `Session.Command`
  Throws:
    `IOException`

### getErrorAsString

    @Deprecated
    public String getErrorAsString()
                            throws IOException

  Deprecated.

  Specified by:
    `getErrorAsString` in interface `Session.Command`
  Throws:
    `IOException`

Copyright © 2009-2011. All Rights Reserved.