5 * Created by Sarah Westcott on 7/8/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "systemcommand.h"
12 //**********************************************************************************************************************
13 vector<string> SystemCommand::getValidParameters(){
15 vector<string> myArray;
19 m->errorOut(e, "SystemCommand", "getValidParameters");
23 //**********************************************************************************************************************
24 vector<string> SystemCommand::getRequiredParameters(){
26 vector<string> myArray;
30 m->errorOut(e, "SystemCommand", "getRequiredParameters");
34 //**********************************************************************************************************************
35 vector<string> SystemCommand::getRequiredFiles(){
37 vector<string> myArray;
41 m->errorOut(e, "SystemCommand", "getRequiredFiles");
45 //**********************************************************************************************************************
47 SystemCommand::SystemCommand(string option) {
51 //allow user to run help
52 if(option == "help") { help(); abort = true; }
55 if (option == "") { m->mothurOut("You must enter a command to run."); m->mothurOutEndLine(); abort = true; }
57 //check for outputdir and inputdir parameters
58 int commaPos = option.find_first_of(',');
60 //if there is a comma then grab string up to that pos
61 if (commaPos != option.npos) {
62 option = option.substr(0, commaPos);
71 m->errorOut(e, "SystemCommand", "SystemCommand");
75 //**********************************************************************************************************************
77 void SystemCommand::help(){
79 m->mothurOut("The system command allows you to execute a system command from within mothur.\n");
80 m->mothurOut("The system has no parameters.\n");
81 m->mothurOut("The system command should be in the following format: system(yourCommand).\n");
82 m->mothurOut("Example system(clear).\n");
85 m->errorOut(e, "SystemCommand", "help");
90 //**********************************************************************************************************************
92 int SystemCommand::execute(){
95 if (abort == true) { return 0; }
97 system(command.c_str());
102 catch(exception& e) {
103 m->errorOut(e, "SystemCommand", "execute");
108 //**********************************************************************************************************************