-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]On Behalf Of Jeff Garland Sent: den 11 augusti 2004 17:19 To: boost-users@lists.boost.org Subject: Re: [Boost-users] Feature for using C++ as script language
On Wed, 11 Aug 2004 11:33:50 -0300, MaurĂcio wrote
Hi,
After I discovered Boost, which has regex and filesystem libraries, I decided to use C++ for tasks that I usually do with Ruby (a Perl-like language), because I know C++ a lot better than other languages. However, there's a feature of those languages I miss: the ability to call external programs and get the output as a string. Does any of Boost libraries (or other free libraries you know) have this capability?
There isn't a boost library, but it would be a nice addition. Turns out the 'system' call is available on both windows and unix so you can do something like this:
#include
std::string command = "...your command here..." std::string tmpfile_name("...your temporary file name here..."); std::string cmd = command + "> " + tmpfile_name; system(cmd.c_str()); std::ifstream output(tmpfile_name.c_str());
Of course this has many limits an issues. If you want something more formal pstreams might work for you:
http://pstreams.sourceforge.net/
HTH,
Jeff
Another one is here: http://libexecstream.sourceforge.net/ / Jonas