5 * Created by Sarah Westcott on 7/8/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "systemcommand.h"
12 //**********************************************************************************************************************
14 SystemCommand::SystemCommand(string option) {
18 //allow user to run help
19 if(option == "help") { help(); abort = 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 void SystemCommand::help(){
46 m->mothurOut("The system command allows you to execute a system command from within mothur.\n");
47 m->mothurOut("The system has no parameters.\n");
48 m->mothurOut("The system command should be in the following format: system(yourCommand).\n");
49 m->mothurOut("Example system(clear).\n");
52 m->errorOut(e, "SystemCommand", "help");
57 //**********************************************************************************************************************
59 int SystemCommand::execute(){
62 if (abort == true) { return 0; }
64 system(command.c_str());
70 m->errorOut(e, "SystemCommand", "execute");
75 //**********************************************************************************************************************