Class CommandResponse
Describes the results of a command executed on the remote server using RunCommand(CommandBundle, RunOptions) or SudoCommand(string, params object[]).
Implements
Namespace: Neon.SSH
Assembly: Neon.SSH.dll
Syntax
public class CommandResponse : IBashCommandFormatter
Properties
AllText
Returns the command standard output and error as a string.
Declaration
public string AllText { get; }
Property Value
Type | Description |
---|---|
string |
BashCommand
Returns the command nicely formatted across multiple lines of text that is suitable for including in a Bash script.
Declaration
public string BashCommand { get; }
Property Value
Type | Description |
---|---|
string |
Command
Returns the original command line.
Declaration
public string Command { get; }
Property Value
Type | Description |
---|---|
string |
ErrorSummary
Returns an error message suitable for including in a related exception message.
Declaration
public string ErrorSummary { get; }
Property Value
Type | Description |
---|---|
string |
ErrorText
Returns the command standard error as a string.
Declaration
public string ErrorText { get; }
Property Value
Type | Description |
---|---|
string |
ExitCode
Returns the command exit code.
Declaration
public int ExitCode { get; }
Property Value
Type | Description |
---|---|
int |
OutputBinary
Returns the command standard output as a byte array when BinaryOutput is specified.
Declaration
public byte[] OutputBinary { get; }
Property Value
Type | Description |
---|---|
byte[] |
OutputText
Returns the command standard output as a string when BinaryOutput is not specified.
Declaration
public string OutputText { get; }
Property Value
Type | Description |
---|---|
string |
ProxyIsFaulted
Indicates whether the command failed because the proxy is faulted due to a previous error.
Declaration
public bool ProxyIsFaulted { get; }
Property Value
Type | Description |
---|---|
bool |
Success
Returns true
if the command exit code was zero,
false otherwise.
Declaration
public bool Success { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
EnsureSuccess()
Ensures that the response has a zero exit code.
Declaration
public CommandResponse EnsureSuccess()
Returns
Type | Description |
---|---|
CommandResponse | The same CommandResponse to support fluent coding styles. |
Exceptions
Type | Condition |
---|---|
ExecuteException | Thrown if when ExitCode is non-zero. |
OpenAllTextReader()
Creates a TextReader over the command's standard output and standard error results.
Declaration
public TextReader OpenAllTextReader()
Returns
Type | Description |
---|---|
TextReader | The TextReader. |
OpenErrorTextReader()
Creates a TextReader over the command's standard error result.
Declaration
public TextReader OpenErrorTextReader()
Returns
Type | Description |
---|---|
TextReader | The TextReader. |
OpenOutputBinaryStream()
Creates a Stream that can be used to read the standard output as binary when BinaryOutput is specified.
Declaration
public Stream OpenOutputBinaryStream()
Returns
Type | Description |
---|---|
Stream | The Stream. |
OpenOutputTextReader()
Creates a TextReader over the command's standard output result.
Declaration
public TextReader OpenOutputTextReader()
Returns
Type | Description |
---|---|
TextReader | The TextReader. |
ToBash(string)
Converts the original command into a Bash command.
Declaration
public string ToBash(string comment = null)
Parameters
Type | Name | Description |
---|---|---|
string | comment | Optionally specifies a comment string to be included. |
Returns
Type | Description |
---|---|
string | The Bash command string. |