Feature for using C++ as script language

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? Thanks, Maurício

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 <stdlib.h> 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
participants (2)
-
Jeff Garland
-
Maurício