//**********************************************************************************************************************
vector<string> SystemCommand::setParameters(){
try {
- CommandParameter pcommand("command", "String", "", "", "", "", "",false,false); parameters.push_back(pcommand);
+ CommandParameter pcommand("command", "String", "", "", "", "", "","",false,false); parameters.push_back(pcommand);
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
if (abort == true) { if (calledHelp) { return 0; } return 2; }
- command += " > ./commandScreen.output 2>&1";
- system(command.c_str());
+ //if command contains a redirect don't add the redirect
+ bool usedRedirect = false;
+ if ((command.find('>')) == string::npos) {
+ command += " > ./commandScreen.output 2>&1";
+ usedRedirect = true;
+ }
- ifstream in;
- string filename = "./commandScreen.output";
- m->openInputFile(filename, in);
+ system(command.c_str());
- string output = "";
- while(char c = in.get()){
- if(in.eof()) { break; }
- else { output += c; }
+ if (usedRedirect) {
+ ifstream in;
+ string filename = "./commandScreen.output";
+ m->openInputFile(filename, in, "no error");
+
+ string output = "";
+ while(char c = in.get()){
+ if(in.eof()) { break; }
+ else { output += c; }
+ }
+ in.close();
+
+ m->mothurOut(output); m->mothurOutEndLine();
+ m->mothurRemove(filename);
}
- in.close();
- m->mothurOut(output); m->mothurOutEndLine();
- remove(filename.c_str());
-
return 0;
}