On Tue, Jan 7, 2014 at 8:44 AM, Vincent R.
Hi,
What is the status of boost:process, when looking on internet you can find different version that are more or less compatible. Not an ideal situation and I am a bit surprised that this lib doesn't get more love from c++ dev. Anyway after a long time coding in easier language I decided to do a small project under linux that consists in a tcp server running on linux that start some process initiated by a client and sends the output. So I have downaloaded the most "official" version I could find here http://www.highscore.de/boost/process/ and I tried the following code :
#include <cassert> #include <iostream> #include <map> #include <string> #include <sstream> #include <vector> #include
#include #include namespace asio = boost::asio; namespace bp = boost::process; using asio::ip::tcp;
bp::child start_child() { std::string exec = boost::process::find_executable_in_path("dpkg"); std::vectorstd::string args; args.push_back("-l");
bp::context ctx; ctx.stderr_behavior = bp::capture_stream();
return bp::launch(exec, args, ctx); }
int main(int argc, char *argv[]) { std::string value;
bp::child c = start_child(); bp::pistream &is = c.get_stderr(); std::string line; while (std::getline(is, line)) { value += line + "\r\n"; } c.wait();
std::cout << "OUTPUT: " << value << std::endl;
return 0; }
My first question is how can I merge the stderr with stdout because some commands use stdout and some others stderr ?
My second question is : why the code above doesn't work properly and doesn't handle the arguments I am passing ? Indeed when I run the code I get the following output :
OUTPUT: dpkg: error: need an action option
it means that the -l is not taken in consideration.
Thanks for any help
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
For what its worth, this is the more recent version: http://www.highscore.de/boost/process0.5/ Brian