简体   繁体   English

ACE_OS:execlp获取结果-标准输出

[英]ACE_OS:execlp get result - stdout

After several hours of googling I'm still failing to understand how to obtain result from ACE_OS::execlp command. 经过几个小时的搜寻后,我仍然无法理解如何从ACE_OS :: execlp命令获取结果。 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. 例如,如果我调用一些bash脚本,它会生成其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 ) 恐怕这个功能似乎没有实现:根据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 : 或者,您可以使用<cstdlib> (如果编译器链支持)和类似以下的代码:

#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 http://en.cppreference.com/w/cpp/utility/program/system所示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM