# Session (sshj 0.4.1 API)
Date: 2011-06-19

## net.schmizz.sshj.connection.channel.direct
Interface Session

All Superinterfaces:
  Channel, Closeable, ErrorNotifiable, SSHPacketHandler

All Known Implementing Classes:
  SessionChannel

    public interface Session

extends Channel

A `session` channel provides for execution of a remote `command`, `shell` or `subsystem`. Before this requests like starting X11 forwarding, setting environment variables, allocating a PTY etc. can be made.

It is not legal to reuse a `session` channel for more than one of command, shell, or subsystem. Once one of these has been started this instance's API is invalid and that of the `specific` `targets` `returned` should be used.

See Also:
  `Session.Command`, `Session.Shell`, `Session.Subsystem`

Nested Class Summary
`static interface` `Session.Command` Command API.
`static interface` `Session.Shell` Shell API.
`static interface` `Session.Subsystem` Subsystem API.

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`

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.
`Session.Command` `exec(String command)` Execute a remote command.
`void` `reqX11Forwarding(String authProto, String authCookie, int screen)` Request X11 forwarding.
`void` `setEnvVar(String name, String value)` Set an enviornment variable.
`Session.Shell` `startShell()` Request a shell.
`Session.Subsystem` `startSubsystem(String name)` Request a subsystem.

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`

Methods inherited from interface net.schmizz.sshj.common.ErrorNotifiable
`notifyError`

Method Detail

### allocateDefaultPTY

    void allocateDefaultPTY()
                            throws ConnectionException,
                                   TransportException

  Allocates a default PTY. The default PTY is `"vt100"` with the echo modes disabled.

  Throws:
    `ConnectionException`
    `TransportException`

### allocatePTY

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

  Allocate a psuedo-terminal for this session.

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

  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)
    `modes` -
  Throws:
    `ConnectionException`
    `TransportException`

### exec

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

  Execute a remote command.

  Parameters:
    `command` -
  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

### reqX11Forwarding

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

  Request X11 forwarding.

  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

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

  Set an enviornment variable.

  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

### startShell

    Session.Shell startShell()
                             throws ConnectionException,
                                    TransportException

  Request a shell.

  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

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

  Request a subsystem.

  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

Copyright © 2009-2011. All Rights Reserved.