X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=systemcommand.cpp;h=5ace75e3a2d152f27e6483aab2ad4a697f952c79;hb=75962c819c16814e5c2340d99af1aa62e564dc20;hp=e5aeb3e8b73dfb59008f6ddccaa3b0703b25e696;hpb=fe0f86cb70ff3ce31df98ed49e404c7e12e21b3d;p=mothur.git diff --git a/systemcommand.cpp b/systemcommand.cpp index e5aeb3e..5ace75e 100644 --- a/systemcommand.cpp +++ b/systemcommand.cpp @@ -91,20 +91,23 @@ int SystemCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } - //system(command.c_str()); - FILE *lsofFile_p = popen(command.c_str(), "r"); + command += " > ./commandScreen.output 2>&1"; + system(command.c_str()); - if (!lsofFile_p) { return 0; } + ifstream in; + string filename = "./commandScreen.output"; + m->openInputFile(filename, in); - char buffer[1024]; - while ( fgets(buffer, 1024, lsofFile_p) != NULL ) { - string temp = buffer; - m->mothurOut(temp); + string output = ""; + while(char c = in.get()){ + if(in.eof()) { break; } + else { output += c; } } - m->mothurOutEndLine(); - - pclose(lsofFile_p); + in.close(); + m->mothurOut(output); m->mothurOutEndLine(); + remove(filename.c_str()); + return 0; }