Top Description Fields Constructors Methods
org.apache.sshd.common.channel

public final Class SttySupport

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .InputStream, .OutputStream, java.nio.charset.Charset, java.util.EnumMap, .Map, .StringTokenizer, java.util.concurrent.atomic.AtomicLong, .AtomicReference

Support for stty command on unix
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
public static final String
public static final int
public static final int
public static final String
private static final AtomicReference<String>
private static final AtomicReference<String>
private static final AtomicLong

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static int
public static String

Returns:

The execution result
exec
(final String
The command to execute
cmd
)

Execute the specified command and return the output (both stdout and stderr).

private static String

Returns:

The execution result
exec
(String...
The command components
cmd
)

Execute the specified command and return the output (both stdout and stderr).

private static int
findChar(String stty, String name)

private static int
findFlag(String stty, String name)

public static String

Returns:

The command to use to set the terminal options.
getSttyCommand
()

public static int

Returns:

The terminal height
getTerminalHeight
()

Returns the value of "stty size" height param

Note

this method caches the value from the first time it is called in order to increase speed, which means that changing to size of the terminal will not be reflected in the console.

public static int
public static int

Returns:

The terminal width
getTerminalWidth
()

Returns the value of "stty size" width param

Note

this method caches the value from the first time it is called in order to increase speed, which means that changing to size of the terminal will not be reflected in the console.

public static String
public static Map<PtyMode, Integer>
public static Map<PtyMode, Integer>
public static void
setSttyCommand(String
The command to use to set the terminal options. Defaults to DEFAULT_SSHD_STTY_COMMAND, or the value of the SSHD_STTY_COMMAND_PROP system property if not set via this method
cmd
)

public static String

Returns:

The execution result
stty
(String
The command arguments
args
)

Execute the stty command with the specified arguments against the current active terminal.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_SSHD_STTY_COMMANDback to summary
public static final String DEFAULT_SSHD_STTY_COMMAND
DEFAULT_TERMINAL_HEIGHTback to summary
public static final int DEFAULT_TERMINAL_HEIGHT
DEFAULT_TERMINAL_WIDTHback to summary
public static final int DEFAULT_TERMINAL_WIDTH
SSHD_STTY_COMMAND_PROPback to summary
public static final String SSHD_STTY_COMMAND_PROP
STTY_COMMAND_HOLDERback to summary
private static final AtomicReference<String> STTY_COMMAND_HOLDER
TTY_PROPS_HOLDERback to summary
private static final AtomicReference<String> TTY_PROPS_HOLDER
TTY_PROPS_LAST_FETCHED_HOLDERback to summary
private static final AtomicLong TTY_PROPS_LAST_FETCHED_HOLDER

Constructor Detail

SttySupportback to summary
private SttySupport()

Method Detail

copyStreamback to summary
private static int copyStream(InputStream in, OutputStream bout) throws IOException
execback to summary
public static String exec(final String cmd) throws IOException, InterruptedException

Execute the specified command and return the output (both stdout and stderr).

Parameters
cmd:String

The command to execute

Returns:String

The execution result

Exceptions
IOException:
If failed to execute the command
InterruptedException:
If interrupted while awaiting command execution
See Also
exec(String[])
execback to summary
private static String exec(String... cmd) throws IOException, InterruptedException

Execute the specified command and return the output (both stdout and stderr).

Parameters
cmd:String[]

The command components

Returns:String

The execution result

Exceptions
IOException:
If failed to execute the command
InterruptedException:
If interrupted while awaiting command execution
findCharback to summary
private static int findChar(String stty, String name)
findFlagback to summary
private static int findFlag(String stty, String name)
getSttyCommandback to summary
public static String getSttyCommand()
Returns:String

The command to use to set the terminal options.

See Also
setSttyCommand(String)
getTerminalHeightback to summary
public static int getTerminalHeight()

Returns the value of "stty size" height param

Note

this method caches the value from the first time it is called in order to increase speed, which means that changing to size of the terminal will not be reflected in the console.

Returns:int

The terminal height

getTerminalPropertyback to summary
public static int getTerminalProperty(String prop) throws IOException, InterruptedException
getTerminalWidthback to summary
public static int getTerminalWidth()

Returns the value of "stty size" width param

Note

this method caches the value from the first time it is called in order to increase speed, which means that changing to size of the terminal will not be reflected in the console.

Returns:int

The terminal width

getTtyPropsback to summary
public static String getTtyProps() throws IOException, InterruptedException
getUnixPtyModesback to summary
public static Map<PtyMode, Integer> getUnixPtyModes() throws IOException, InterruptedException
parsePtyModesback to summary
public static Map<PtyMode, Integer> parsePtyModes(String stty)
setSttyCommandback to summary
public static void setSttyCommand(String cmd)
Parameters
cmd:String

The command to use to set the terminal options. Defaults to DEFAULT_SSHD_STTY_COMMAND, or the value of the SSHD_STTY_COMMAND_PROP system property if not set via this method

sttyback to summary
public static String stty(String args) throws IOException, InterruptedException

Execute the stty command with the specified arguments against the current active terminal.

Parameters
args:String

The command arguments

Returns:String

The execution result

Exceptions
IOException:
If failed to execute the command
InterruptedException:
If interrupted while awaiting command execution
See Also
exec(String)