# Shell.CommandOutput

Artifact: [androidx.test.uiautomator:uiautomator-shell](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/shell/Shell.kt+class:androidx.test.shell.Shell.CommandOutput) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

*** ** * ** ***


```
public final class Shell.CommandOutput
```

<br />

*** ** * ** ***

The output of a shell command executed via `https://developer.android.com/reference/androidx/test/shell/Shell#command(kotlin.String)`. This class offers access to the `https://developer.android.com/reference/androidx/test/shell/Shell.CommandOutput#stdOut()` and `https://developer.android.com/reference/androidx/test/shell/Shell.CommandOutput#stdErr()` of the launched command, with utility methods to wait for the full output or parse the stream incrementally.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/test/shell/Shell.CommandOutput#CommandOutput(kotlin.String,androidx.test.shell.ShellProcess)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html command, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/shell/ShellProcess shellProcess)` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/shell/Shell.CommandOutput#getStdErr()()` Awaits the process termination and returns the full stderr of the launched command. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/InputStream.html` | `https://developer.android.com/reference/androidx/test/shell/Shell.CommandOutput#getStdErrStream()()` Allows incrementally consuming the stderr of a single command as an `https://developer.android.com/reference/java/io/InputStream.html`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/shell/Shell.CommandOutput#getStdOut()()` Awaits the process termination and returns the full stdout of the launched command. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/InputStream.html` | `https://developer.android.com/reference/androidx/test/shell/Shell.CommandOutput#getStdOutStream()()` Allows incrementally consuming the stdout of a single command as an `https://developer.android.com/reference/java/io/InputStream.html`. |
| `final boolean` | `https://developer.android.com/reference/androidx/test/shell/Shell.CommandOutput#isRunning()()` Returns whether the launched shell command is still running. |

## Public constructors

### CommandOutput

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public CommandOutput(@NonNull String command, @NonNull ShellProcess shellProcess)
```

## Public methods

### getStdErr

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public final @NonNull String getStdErr()
```

Awaits the process termination and returns the full stderr of the launched command.

### getStdErrStream

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public final @NonNull InputStream getStdErrStream()
```

Allows incrementally consuming the stderr of a single command as an `https://developer.android.com/reference/java/io/InputStream.html`.

### getStdOut

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public final @NonNull String getStdOut()
```

Awaits the process termination and returns the full stdout of the launched command.

### getStdOutStream

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public final @NonNull InputStream getStdOutStream()
```

Allows incrementally consuming the stdout of a single command as an `https://developer.android.com/reference/java/io/InputStream.html`.

### isRunning

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public final boolean isRunning()
```

Returns whether the launched shell command is still running.