# io.github.libtmux.Pane.Pane.run

- **Module:** io.github.libtmux.Pane.Pane
- **Package:** io.github.libtmux:libtmux
- **Language:** Java
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-java/blob/842228310449e879ebcaa3f910597757c9dbffd6/libtmux/src/main/java/io/github/libtmux/Pane.java#L439
- **Page:** https://libtmux.org/en/java/latest/reference/io-github-libtmux-pane-pane-run/

```
io.github.libtmux.Pane.Pane.run(command: String, timeout: Duration) -> PaneRun
```

Runs a shell command in this pane to its end, and answers with its exit status and output.

**Reach for this first** whenever the command is yours. Nothing is inferred from
the screen: the command runs in a subshell of the pane's own shell, whose trap reports {@code $?}
and signals a private {@code wait-for} channel, so the wait is tmux's and the status is the
shell's. The trap covers interrupt and terminate as well as exit, so a command someone stops at
the pane ends this call with the status it was stopped with rather than leaving it waiting. The output is what the command printed and nothing else — not the typed line,
not the prompt — cut out between two markers the plumbing prints around it.

It runs in the shell a person set up — its directory, its environment, a virtualenv someone
activated — which is the reason to type it there rather than start a process of your own. The
pane has to be running a POSIX shell for the typed line to mean what it says.

A command still running at the deadline keeps running; the answer carries what it had printed
by then, and {@link PaneRun#exact()} is false.

## Parameters

- `command` (String): a line of shell, run as {@code eval} would run it
- `timeout` (Duration): how long to wait for it to end

## Raises

- `IllegalStateException`: if the pane is not running a POSIX shell
- `InterruptedException`: if the waiting thread is interrupted

## Example

```java
PaneRun built = pane.run("make test", Duration.ofMinutes(5));
if (!built.succeeded()) {
System.err.println(String.join("\n", built.output()));
}
```
