Thread: What Libraries and Headers would be good to use to wrap an bash script?

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    4,035

    What Libraries and Headers would be good to use to wrap an bash script?

    What Libraries and Headers would be good to use to wrap an bash script?

    I am thinking to try learning C++ once more.

    Decided that writing small useful programs would be a better path than trying to add features complex programs others have written.

    There is an MSys2 (Cygwin like enviroment) wx-config script that would be better if it was wrapped by an C++ command line program.

    wx-config is something like pkg-config for just the C++ wxWidgets library.

    And, the command line options are not exactly like what the CodeLite IDE wants under the Windows OS.

    Therefore, I need to add a few options and pass some options onto the MSys2 bash call of the wx-config script.

    I wish to use libraries/classes that are standard in C++ or Boost.

    I see two types of libraries/classes I need suggests of which ones to research.
    1. Ones to handle command line options
    I have found
    Code:
    boost::program_options
    by using web search.
    2. Ones to call external command line programs and record the response from the program.
    I have failed to find any class that does something like C's system or exec functions.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,126
    How about Chapter 30. Boost.Process - 1.76.0

    Quote:
    Boost.Process is a library to manage system processes. It can be used to:
    * create child processes
    * setup streams for child processes
    * communicate with child processes through streams (synchronously or asynchronously)
    * wait for processes to exit (synchronously or asynchronously)
    * terminate processes

    Here's a simple example of how to start a program with Boost.Process:
    Code:
    #include <boost/process.hpp>
    #include <string>
    #include <iostream>
     
    using namespace boost::process;
     
    int main()
    {
        ipstream pipe_stream;
        child c("gcc --version", std_out > pipe_stream);
     
        std::string line;
     
        while (pipe_stream && std::getline(pipe_stream, line) && !line.empty())
            std::cerr << line << std::endl;
     
        c.wait();
    }
    The best argument against democracy is a five minute conversation with the average voter. - Churchill

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,035
    john.c: Thank you. I figured there had to be a class.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bash script in c
    By programmerc in forum C Programming
    Replies: 1
    Last Post: 10-02-2014, 08:47 PM
  2. exec a bash script
    By quo in forum Linux Programming
    Replies: 17
    Last Post: 06-02-2012, 06:01 AM
  3. Awk and sed bash script help
    By Annonymous in forum Linux Programming
    Replies: 19
    Last Post: 05-10-2012, 12:40 AM
  4. ssh/bash script question
    By Overworked_PhD in forum Tech Board
    Replies: 2
    Last Post: 03-30-2009, 07:48 PM
  5. Bash Script Q
    By QuestionC in forum Tech Board
    Replies: 1
    Last Post: 04-19-2007, 10:16 AM

Tags for this Thread