Overview
Features
Download
Documentation
Community
Add-Ons & Services

executing external commands from poco

Please post support and help requests here.

executing external commands from poco

Postby argoneus » 02 Jul 2007, 17:36

is there a Poco equivalent of the C++ system() function to execute an external command? i'm running against a limitation of system() and was wondering if Poco provided similar (perhaps more flexible) functionality. Thank you.
argoneus
 
Posts: 12
Joined: 19 Oct 2006, 19:03

Re: executing external commands from poco

Postby guenter » 03 Jul 2007, 08:57

See the Process class in the Foundation library, and the Process::launch() member function in the different variants.

To get system() - like behaviour with Process::launch(), you'll have to explicitly create a shell process that executes a command.

On Windows:
Code: Select all

Process: :Args args;
args.push_back("/C");
args.push_back("DIR");
Process: :launch("CMD.EXE", args);
...


On Unix:
Code: Select all

Process: :Args args;
args.push_back("-c");
args.push_back("ls");
Process: :launch("sh", args);
...


There is also another variant of Process::launch() that supports I/O redirection using pipes and iostreams.
guenter
 
Posts: 1105
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron