FBB::Co...tractor(3bobcat)

πŸ¦‹ NAME πŸ¦‹

FBB::CoutExtractor β€” runs external programs and catches the standard output they write πŸ’…


✨ SYNOPSIS ✨

#include <bobcat/coutextractor>
Linking option: -lbobcat

πŸ’– DESCRIPTION πŸ’–

okay so, bestie, listen πŸ‘‘ The FBB::CoutExtractor class gives you a basic interface for calling external programs (the so-called child processes) that write to their standard output streams. By default, an object of this type does not handle the child process's standard input or standard error streams β€” nope, not those, not by default πŸ™ˆ. What it does do is read the child's standard output through the CoutExtractor object: anything the child process writes to its standard output gets extracted (i.e. read) from the CoutExtractor object πŸ’–.

ngl, there's a catch: the PATH environment variable is not used when calling child processes. So child process programs have to be specified using paths. That's the vibe, fr fr πŸŽ€

You can reuse CoutExtractor objects over and over to execute the same child process or a completely different one. Recycling is main character energy β™»οΈβœ¨

Arguments passed to child processes may be surrounded by double or single quotes:

  • double-quoted arguments β†’ the double quotes get removed, and any escape-sequences inside are interpreted πŸͺ„
  • single-quoted arguments β†’ the single quotes get removed, and the content is accepted exactly as-is πŸ’…
  • unquoted escape-sequences can also be specified β†’ those get evaluated and replaced by their intended characters (like \100 becomes @) πŸ”₯

🌈 NAMESPACE 🌈

FBB

Every constructor, member, operator and manipulator mentioned in this man-page lives in the namespace FBB πŸ’œ


🌸 INHERITS FROM 🌸

FBB::Exec (private), FBB::IFdBuf (private), std::istream


πŸŽ€ CONSTRUCTOR πŸŽ€

  • CoutExtractor(size_t bufSize = 100) β€” you may pass a bufSize argument; it defines the internal buffer size used by the CoutExtractor's streambuf. By default the standard input and standard error streams are not handled.
  • CoutExtractor(Mode mode, size_t bufSize = 100) β€” the mode argument must be CoutExtractor::CLOSE_STD. It says that the standard input and standard error streams get redirected to /dev/null: the child processes then can't read their standard input streams, and any standard error output the child processes generate is ignored πŸ’€. A bufSize argument may also be specified: it defines the internal buffer size used by the CinInserter's streambuf.
Copy and move constructors (and assignment operators) are not available. Not even a little bit. Periodt 🚫

✨ MEMBERS ✨

  • void 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 🫢). This member returns immediately, and after that, any information the child process writes to its standard output stream may be extracted from the CoutExtractor object.

Once execute has returned you can call it again, either with the same command or another one 🌟

Arguments passed to the program being executed as a child process may optionally be specified using single or double quotes, as described in this man-page's DESCRIPTION section πŸ’–

  • int ret() const β€” once execute has returned, this member gives you the actual exit code of the child process. Before the first execute call, its value equals -1 ⭐

πŸ”’ PROTECTED MEMBER πŸ”’

  • Pipe &childOutPipe() β€” if derived classes need to override the redirection-members, then they probably need access to the pipe the child process writes to. 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 output into the pipe πŸ¦‹

πŸ”₯ EXAMPLE πŸ”₯

#include <iostream>

#include <bobcat/coutextractor>

using namespace std;
using namespace FBB;

int main()
{
    CoutExtractor 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/coutextractor β€” provides the class interface πŸ’…


πŸ’œ SEE ALSO πŸ’œ

bobcat(7), cerrextractor(3bobcat), cininserter(3bobcat), execl(3), exec(3bobcat), fork(3bobcat), process(3bobcat), stdextractor(3bobcat).


πŸ™ˆ BUGS πŸ™ˆ

None reported. We ate and left no crumbs 😌✨


🧚 BOBCAT PROJECT FILES 🧚

Debian Bobcat project files:

  • libbobcat6: debian package containing the shared library, changelog and copyright note;
  • 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. Iconic, honestly πŸ’…


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


πŸŽ€ AUTHOR πŸŽ€

Frank B. Brokken (f.b.brokken@rug.nl). Legend behaviour, no cap πŸ‘‘


k that's the whole thing, bestie πŸ’– This was FBB::Co...tractor(3bobcat), the "Executing Child Processes" page, from libbobcat-dev_6.15.01, dated 2005-2026. Go read /bin/cat some files and stream their output, you got this πŸ¦‹βœ¨

πŸ“¦ where this page comes from