# libtmux::Server::run_shell

- **Module:** libtmux::Server
- **Package:** libtmux-cxx
- **Language:** C++
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-cxx/blob/85e8bd603a322dc32bb8b9aeb1a72bcf36945f1d/include/libtmux/server.hpp#L253
- **Page:** https://libtmux.org/reference/cxx/libtmux-server-run_shell/

```
libtmux::Server::run_shell(command: std::string_view, background: bool = false) -> expected< void, CommandFailure >
```

Run a shell command on the machine the server is on.

Reports whether it ran, not what it printed. tmux hands back the output on most versions and discards it on 3.3a and 3.4, and an answer that is empty on two versions in the middle of the range is worse than no answer at all. A caller that needs the output redirects it to a file.

What is uniform is the exit status: a command that fails is a failure here, carrying its code in `exit_code`.

`background` is tmux's `-b`, which returns as soon as the command is started. Nothing can then be said about how it ended, so a backgrounded command that fails still reports success.
