5 * Created by Sarah Westcott on 7/8/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "systemcommand.h"
13 //**********************************************************************************************************************
14 SystemCommand::SystemCommand(string option) {
16 abort = false; calledHelp = false;
18 //allow user to run help
19 if(option == "help") { help(); abort = true; calledHelp = true; }
22 if (option == "") { m->mothurOut("You must enter a command to run."); m->mothurOutEndLine(); abort = true; }
24 //check for outputdir and inputdir parameters
25 int commaPos = option.find_first_of(',');
27 //if there is a comma then grab string up to that pos
28 if (commaPos != option.npos) {
29 option = option.substr(0, commaPos);
38 m->errorOut(e, "SystemCommand", "SystemCommand");
42 //**********************************************************************************************************************
44 string SystemCommand::getHelpString(){
46 string helpString = "";
47 helpString += "The system command allows you to execute a system command from within mothur.\n";
48 helpString += "The system has no parameters.\n";
49 helpString += "The system command should be in the following format: system(yourCommand).\n";
50 helpString += "Example system(clear).\n";
54 m->errorOut(e, "SystemCommand", "help");
59 //**********************************************************************************************************************
61 int SystemCommand::execute(){
64 if (abort == true) { if (calledHelp) { return 0; } return 2; }
66 system(command.c_str());
72 m->errorOut(e, "SystemCommand", "execute");
77 //**********************************************************************************************************************