After several hours of googling I'm still failing to understand how to obtain result from ACE_OS::execlp command. Here I need to obtain not the status itself but the output result. For instance if I call some bash script and it produces its stdout/stderr.
Can anybody help me how to obtain it?
Thank you!
I am afraid this function seems not implemented: according to the github (https://github.com/DOCGroup/ACE_TAO/blob/master/ACE/ace/OS_NS_unistd.cpp)
and the code :
int
ACE_OS::execlp (const char * /* file */, const char * /* arg0 */, ...)
{
ACE_OS_TRACE ("ACE_OS::execlp");
ACE_NOTSUP_RETURN (-1);
// Need to write this code.
// ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
}
Alternatively you could use the <cstdlib>
(if supported by your compiler chain) and a code like :
#include <cstdlib>
#include <fstream>
#include <iostream>
int main()
{
std::system("ls -l >test.txt"); // execute the UNIX command "ls -l >test.txt"
std::cout << std::ifstream("test.txt").rdbuf();
}
as seen at http://en.cppreference.com/w/cpp/utility/program/system