Ticket #5923: version.cpp

File version.cpp, 811 bytes (added by Owen Arnold, 8 years ago)
Line 
1#include "Poco/Process.h"
2#include "Poco/PipeStream.h"
3#include "Poco/StreamCopier.h"
4#include <sstream>
5#include <iostream>
6
7using Poco::Process;
8using Poco::ProcessHandle;
9
10int main(int argc, char** argv)
11{
12  std::string cmd("/home/dmn58364/Builds/paraview-3.10/release/bin/paraview");
13  std::vector<std::string> args;
14  args.push_back("-V");
15  Poco::Pipe outPipe, errPipe;
16  ProcessHandle ph = Process::launch(cmd, args, 0, &outPipe, &errPipe);
17  // Read from the pipes
18  Poco::PipeInputStream stdout(outPipe), stderr(errPipe);
19  std::ostringstream outStream, errStream;
20  Poco::StreamCopier::copyStream(stdout, outStream);
21  Poco::StreamCopier::copyStream(stderr, errStream);
22  std::cout << "stdout =\"" << outStream.str() << "\"\n";
23  std::cout << "stderr =\"" << errStream.str() << "\"\n";
24  return 0;
25}
26