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

# cerrextractor(3bobcat)

Runs external programs writing standard error

## NAME

FBB::CerrExtractor - Runs external programs writing standard error

## SYNOPSIS

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

## DESCRIPTION

The **FBB::CerrExtractor** class offers a basic interface for calling external programs (so-called *child processes*) writing their standard error streams. The standard input and standard output streams of the child processes are by default not handled by *CerrExtractor* objects. The child’s standard error is read through the *CerrExtractor* object: information written by the child process to its standard error stream is extracted or read from *CerrExtractor* object. The *PATH* environment variable is not used when calling child processes: child process programs must be specified using paths.

*CerrExtractor* objects may repeatedly be used to execute the same or different child processes.

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::Exec** (private), **FBB::IFdBuf** (private), **std::istream**

## CONSTRUCTOR

- o

  **CerrExtractor(size\_t bufSize = 100)**:\
   A *bufSize* argument may be specified: it defines the internal buffer size used by the *CerrExtractor’s* streambuf. By default the standard input and standard output streams are not handled.

-

  - o

  **CerrExtractor(Mode mode, size\_t bufSize = 100)**:\
   The *mode* argument must be *CerrExtractor::CLOSE\_STD*. It indicates that the standard input and standard error streams are redirected to */dev/null*: the child processes cannot read their standard input streams and any standard output generated by child processes is ignored. A *bufSize* argument may be specified: it defines the internal buffer size used by the *CinInserter’s* streambuf.

Copy and move constructors (and assignment operators) are not available.

## MEMBERS

- o

  **void execute(std::string const &cmd)**:\
   The argument specifies the command to execute: the command itself must be specified using an absolute path (the *PATH* environment variable isn’t used).  This member immediately returns, after which information written by the child process to its standard error stream may be extracted from the *CerrExtractor* object.

-

  Once *execute* has returned it can be called again, either using the same or another command.

-

  Arguments passed to the program to be executed as child process may optionally 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.

## PROTECTED MEMBER

- o

  **Pipe &childOutPipe()**:\
   If derived classes need to override the redirections-members then they probabaly need access to the pipe written by the child process. This member provides a reference to that pipe. By default the parent process reads information from the pipe, while the child process inserts its standard error output into the pipe.

## EXAMPLE

```
#include <iostream>
#include <bobcat/cerrextractor>
using namespace std;
using namespace FBB;
int main()
{
    CerrExtractor extractor;
    extractor.execute("/bin/cat driver.cc");
    cout << extractor.rdbuf();
    cerr << "Returning: " << extractor.ret() << "\n"
            "again:\n";
    extractor.execute("/bin/cat driver.cc");
    cout << extractor.rdbuf();
    cerr << "Returning: " << extractor.ret() << ’\n’;
}
```

## FILES

*bobcat/cerrextractor* - provides the class interface

## SEE ALSO

[**bobcat**(7)](/bobcat/7.md), [**cininserter**(3bobcat)](/cininserter/3bobcat.md), [**coutextractor**(3bobcat)](/coutextractor/3bobcat.md), [**execl**(3)](/execl/3.md), [**exec**(3bobcat)](/exec/3bobcat.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**).
