Interface Session
-
- All Superinterfaces:
java.lang.AutoCloseable,Channel,java.io.Closeable,ErrorNotifiable,SSHPacketHandler
- All Known Implementing Classes:
SessionChannel
public interface Session extends Channel
Asessionchannel provides for execution of a remotecommand,shellorsubsystem. Before this requests like starting X11 forwarding, setting environment variables, allocating a PTY etc. can be made. It is not legal to reuse asessionchannel 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 thespecifictargetsreturnedshould be used.- See Also:
Session.Command,Session.Shell,Session.Subsystem
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceSession.CommandCommand API.static interfaceSession.ShellShell API.static interfaceSession.SubsystemSubsystem 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
Modifier and Type Method Description voidallocateDefaultPTY()Allocates a default PTY.voidallocatePTY(java.lang.String term, int cols, int rows, int width, int height, java.util.Map<PTYMode,java.lang.Integer> modes)Allocate a psuedo-terminal for this session.Session.Commandexec(java.lang.String command)Execute a remote command.voidreqX11Forwarding(java.lang.String authProto, java.lang.String authCookie, int screen)Request X11 forwarding.voidsetEnvVar(java.lang.String name, java.lang.String value)Set an environment variable.Session.ShellstartShell()Request a shell.Session.SubsystemstartSubsystem(java.lang.String name)Request a subsystem.-
Methods inherited from interface net.schmizz.sshj.connection.channel.Channel
close, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getLoggerFactory, getOutputStream, getRecipient, getRemoteCharset, getRemoteMaxPacketSize, getRemoteWinSize, getType, isEOF, isOpen, join, join, setAutoExpand
-
Methods inherited from interface net.schmizz.sshj.common.ErrorNotifiable
notifyError
-
Methods inherited from interface net.schmizz.sshj.common.SSHPacketHandler
handle
-
-
-
-
Method Detail
-
allocateDefaultPTY
void allocateDefaultPTY() throws ConnectionException, TransportExceptionAllocates a default PTY. The default PTY is"vt100"with the echo modes disabled.
-
allocatePTY
void allocatePTY(java.lang.String term, int cols, int rows, int width, int height, java.util.Map<PTYMode,java.lang.Integer> modes) throws ConnectionException, TransportExceptionAllocate a psuedo-terminal for this session.0dimension parameters will be ignored by the server.- Parameters:
term-TERMenvironment 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:
ConnectionExceptionTransportException
-
exec
Session.Command exec(java.lang.String command) throws ConnectionException, TransportException
Execute a remote command.- Parameters:
command-- Returns:
Session.Commandinstance which should now be used- Throws:
ConnectionException- if the request to execute the command failedTransportException- if there is an error sending the request
-
reqX11Forwarding
void reqX11Forwarding(java.lang.String authProto, java.lang.String authCookie, int screen) throws ConnectionException, TransportExceptionRequest X11 forwarding.- Parameters:
authProto- X11 authentication protocol nameauthCookie- X11 authentication cookiescreen- X11 screen number- Throws:
ConnectionException- if the request failedTransportException- if there was an error sending the request
-
setEnvVar
void setEnvVar(java.lang.String name, java.lang.String value) throws ConnectionException, TransportExceptionSet an environment variable.- Parameters:
name- name of the variablevalue- value to set- Throws:
ConnectionException- if the request failedTransportException- if there was an error sending the request
-
startShell
Session.Shell startShell() throws ConnectionException, TransportException
Request a shell.- Returns:
Session.Shellinstance which should now be used- Throws:
ConnectionException- if the request failedTransportException- if there was an error sending the request
-
startSubsystem
Session.Subsystem startSubsystem(java.lang.String name) throws ConnectionException, TransportException
Request a subsystem.- Parameters:
name- subsystem name- Returns:
Session.Subsysteminstance which should now be used- Throws:
ConnectionException- if the request failedTransportException- if there was an error sending the request
-
-