---
name: "exec"
section: "3bobcat"
platform: "linux"
package: "libbobcat-dev"
version: "6.07.01-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/exec/3bobcat"
---

# exec(3bobcat)

Runs external programs

## NAME

FBB::Exec - Runs external programs

## SYNOPSIS

**#include \<bobcat/exec\>**\
 Linking option: *-lbobcat*

## DESCRIPTION

The **FBB::Exec** class offers a basic interface for calling external programs (so-called *child processes*). The standard streams of the child processes are not handled by *Exec* objects: the parent’s standard streams are used by the child process. The *PATH* environment variable is not used when calling child processes: child process programs must be specified using paths.

*Exec* objects may repeatedly be used to execute the same or different child processes. Before starting the next child process, the current child process must have finished.

Arguments passed to child processes may be surrounded by double or single quotes. Arguments surrounded by double quotes have their double quotes removed, while interpreting any escape-sequences that may have been used within. Arguments surrounded by single quotes have their single quotes removed, while accepting their content as-is. In addition unquoted escape-sequences may be specified: those escape sequences are evaluated and replaced by their intended characters (e.g., *\\100* is converted to *@*).

## NAMESPACE

**FBB**\
 All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace **FBB**.

## INHERITS FROM

**FBB::Fork**

## CONSTRUCTOR

Only the default constructor is supported.

## MEMBERS

- o

  **bool execute(std::string const &cmd)**:\
   The argument specifies the command to execute: the command itself must be specified as a path (the *PATH* environment variable isn’t used). The member returns *true* if the child process’s exit value equals 0. Otherwise *false* is returned. Once *execute* has returned it can be called again, either using the same or another command. The class *Exec* does not offer facilities to forcefully terminate child processes: parent processes are suspended until the child processes have completed. Arguments passed to the program to be executed as child process may optionall be specified using single or double quotes, as described in this man-page’s DESCRIPTION section.

-

  - o

  **int ret() const**:\
   Once *execute* has returned this member provides the actual exit code of the child process. Its value equals -1 before the first *exectue* call.

## EXAMPLE

```
#include <iostream>
#include <bobcat/execfork>
using namespace std;
using namespace FBB;
int main()
{
    ExecFork ef;
    if (ef.execute("/bin/cp driver.cc /tmp"))
        cout << "driver.cc now copied to /tmp\n";
    else
        cout << "could not copy driver.cc to /tmp\n";
    cout << "Again:\n";
    if (ef.execute("/bin/cp driver.cc /tmp"))
        cout << "driver.cc now copied to /tmp\n";
    else
        cout << "could not copy driver.cc to /tmp\n";
}
```

## FILES

*bobcat/exec* - provides the class interface

## SEE ALSO

[**bobcat**(7)](/bobcat/7.md), [**cerrextractor**(3bobcat)](/cerrextractor/3bobcat.md), [**cininserter**(3bobcat)](/cininserter/3bobcat.md), [**coutextractor**(3bobcat)](/coutextractor/3bobcat.md), [**execl**(3)](/execl/3.md), [**fork**(3bobcat)](/fork/3bobcat.md), [**process**(3bobcat)](/process/3bobcat.md), [**stdextractor**(3bobcat)](/stdextractor/3bobcat.md).

## BUGS

None reported.

## BOBCAT PROJECT FILES

- o

  *https://fbb-git.gitlab.io/bobcat/*: gitlab project page;

Debian Bobcat project files:

- o

  *libbobcat6*: debian package containing the shared library, changelog and copyright note;

- o

  *libbobcat-dev*: debian package containing the static library, headers, manual pages, and developer info;

## BOBCAT

Bobcat is an acronym of \`Brokken’s Own Base Classes And Templates’.

## COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

## AUTHOR

Frank B. Brokken (**f.b.brokken@rug.nl**).
