public class

SessionChannel

extends AbstractDirectChannel
implements Session Session.Command Session.Shell Session.Subsystem
java.lang.Object
   ↳ net.schmizz.sshj.connection.channel.AbstractChannel
     ↳ net.schmizz.sshj.connection.channel.direct.AbstractDirectChannel
       ↳ net.schmizz.sshj.connection.channel.direct.SessionChannel

Class Overview

Session implementation.

Summary

[Expand]
Inherited Constants
From class net.schmizz.sshj.connection.channel.AbstractChannel
Fields
private Boolean canDoFlowControl
private final ChannelInputStream err
private String exitErrMsg
private Signal exitSignal
private Integer exitStatus
private boolean usedUp
private Boolean wasCoreDumped
[Expand]
Inherited Fields
From class net.schmizz.sshj.connection.channel.AbstractChannel
Public Constructors
SessionChannel(Connection conn)
Public Methods
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.
Session.Command exec(String command)
Execute a remote command.
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.
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.
Protected Methods
void closeAllStreams()
Called when all I/O streams should be closed.
void eofInputStreams()
Called when EOF has been received.
void gotExtendedData(SSHPacket buf)
[Expand]
Inherited Methods
From class net.schmizz.sshj.connection.channel.direct.AbstractDirectChannel
From class net.schmizz.sshj.connection.channel.AbstractChannel
From class java.lang.Object
From interface java.io.Closeable
From interface net.schmizz.sshj.common.ErrorNotifiable
From interface net.schmizz.sshj.common.SSHPacketHandler
From interface net.schmizz.sshj.connection.channel.Channel
From interface net.schmizz.sshj.connection.channel.Channel.Direct
From interface net.schmizz.sshj.connection.channel.direct.Session
From interface net.schmizz.sshj.connection.channel.direct.Session.Command
From interface net.schmizz.sshj.connection.channel.direct.Session.Shell
From interface net.schmizz.sshj.connection.channel.direct.Session.Subsystem

Fields

private Boolean canDoFlowControl

private final ChannelInputStream err

private String exitErrMsg

private Signal exitSignal

private Integer exitStatus

private boolean usedUp

private Boolean wasCoreDumped

Public Constructors

public SessionChannel (Connection conn)

Parameters
conn

Public Methods

public void allocateDefaultPTY ()

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

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

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

public Boolean canDoFlowControl ()

Whether the client can do local flow control using control-S and control-Q.

Returns
  • boolean value indicating whether 'client can do', or null if no such information was received

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

Sends a window dimension change message.

Parameters
cols Terminal width, columns
rows Terminal height, rows
width Terminal width, pixels
height Terminal height, pixels

public Session.Command exec (String command)

Execute a remote command.

Parameters
command
Returns

public InputStream getErrorStream ()

Returns the command's stderr stream.

public String getExitErrorMessage ()

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.

public Signal getExitSignal ()

Returns the signal if the command exit violently, or null if this information was not received.

public Integer getExitStatus ()

Returns the exit status of the command if it was received, or null if this information was not received.

public 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. Otherwise, this method will return null.

public void handleRequest (String req, SSHPacket buf)

Parameters
req
buf

public void notifyError (SSHException error)

Notifies this object of an error.

Parameters
error

public void reqX11Forwarding (String authProto, String authCookie, int screen)

Request X11 forwarding.

Parameters
authProto X11 authentication protocol name
authCookie X11 authentication cookie
screen X11 screen number

public void setEnvVar (String name, String value)

Set an enviornment variable.

Parameters
name Name of the variable
value Value to set

public void signal (Signal sig)

Send a signal to the remote command.

Parameters
sig The signal

public Session.Shell startShell ()

Request a shell.

Returns

public Session.Subsystem startSubsystem (String name)

Request a subsystem.

Parameters
name Subsystem name
Returns

Protected Methods

protected void closeAllStreams ()

Called when all I/O streams should be closed. Subclasses can override but must call super.

protected void eofInputStreams ()

Called when EOF has been received. Subclasses can override but must call super.

protected void gotExtendedData (SSHPacket buf)

Parameters
buf