Package org.apache.sshd.common.channel
Class SttySupport
- java.lang.Object
-
- org.apache.sshd.common.channel.SttySupport
-
public final class SttySupport extends Object
Support for stty command on unix- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_SSHD_STTY_COMMAND
static int
DEFAULT_TERMINAL_HEIGHT
static int
DEFAULT_TERMINAL_WIDTH
static String
SSHD_STTY_COMMAND_PROP
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
exec(String cmd)
Execute the specified command and return the output (both stdout and stderr).static String
getSttyCommand()
static int
getTerminalHeight()
Returns the value of "stty size" height param.static int
getTerminalProperty(String prop)
static int
getTerminalWidth()
Returns the value of "stty size" width param.static String
getTtyProps()
static Map<PtyMode,Integer>
getUnixPtyModes()
static Map<PtyMode,Integer>
parsePtyModes(String stty)
static void
setSttyCommand(String cmd)
static String
stty(String args)
Execute the stty command with the specified arguments against the current active terminal.
-
-
-
Field Detail
-
DEFAULT_TERMINAL_WIDTH
public static final int DEFAULT_TERMINAL_WIDTH
- See Also:
- Constant Field Values
-
DEFAULT_TERMINAL_HEIGHT
public static final int DEFAULT_TERMINAL_HEIGHT
- See Also:
- Constant Field Values
-
SSHD_STTY_COMMAND_PROP
public static final String SSHD_STTY_COMMAND_PROP
- See Also:
- Constant Field Values
-
DEFAULT_SSHD_STTY_COMMAND
public static final String DEFAULT_SSHD_STTY_COMMAND
- See Also:
- Constant Field Values
-
-
Method Detail
-
getUnixPtyModes
public static Map<PtyMode,Integer> getUnixPtyModes() throws IOException, InterruptedException
- Throws:
IOException
InterruptedException
-
getTerminalWidth
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:
- The terminal width
-
getTerminalHeight
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:
- The terminal height
-
getTerminalProperty
public static int getTerminalProperty(String prop) throws IOException, InterruptedException
- Throws:
IOException
InterruptedException
-
getTtyProps
public static String getTtyProps() throws IOException, InterruptedException
- Throws:
IOException
InterruptedException
-
stty
public static String stty(String args) throws IOException, InterruptedException
Execute the stty command with the specified arguments against the current active terminal.- Parameters:
args
- The command arguments- Returns:
- The execution result
- Throws:
IOException
- If failed to execute the commandInterruptedException
- If interrupted while awaiting command execution- See Also:
exec(String)
-
exec
public static String exec(String cmd) throws IOException, InterruptedException
Execute the specified command and return the output (both stdout and stderr).- Parameters:
cmd
- The command to execute- Returns:
- The execution result
- Throws:
IOException
- If failed to execute the commandInterruptedException
- If interrupted while awaiting command execution- See Also:
exec(String[])
-
getSttyCommand
public static String getSttyCommand()
- Returns:
- The command to use to set the terminal options.
- See Also:
setSttyCommand(String)
-
setSttyCommand
public static void setSttyCommand(String cmd)
- Parameters:
cmd
- The command to use to set the terminal options. Defaults toDEFAULT_SSHD_STTY_COMMAND
, or the value of theSSHD_STTY_COMMAND_PROP
system property if not set via this method
-
-