37B73C761004BEFD008C4B41 /* listseqscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B73C751004BEFD008C4B41 /* listseqscommand.cpp */; };
37B73CA61004D89A008C4B41 /* getseqscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B73CA51004D89A008C4B41 /* getseqscommand.cpp */; };
37B73CC01004EB38008C4B41 /* removeseqscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B73CBF1004EB38008C4B41 /* removeseqscommand.cpp */; };
+ 37B73CCF1004F5E0008C4B41 /* systemcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B73CCE1004F5E0008C4B41 /* systemcommand.cpp */; };
37C1D9730F86506E0059E3F0 /* binsequencecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C1D9720F86506E0059E3F0 /* binsequencecommand.cpp */; };
37C753CE0FB3415200DBD02E /* distancecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C753CD0FB3415200DBD02E /* distancecommand.cpp */; };
37D928550F21331F001D4494 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927B80F21331F001D4494 /* ace.cpp */; };
37B73CA51004D89A008C4B41 /* getseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getseqscommand.cpp; sourceTree = "<group>"; };
37B73CBE1004EB38008C4B41 /* removeseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = removeseqscommand.h; sourceTree = "<group>"; };
37B73CBF1004EB38008C4B41 /* removeseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removeseqscommand.cpp; sourceTree = "<group>"; };
+ 37B73CCD1004F5E0008C4B41 /* systemcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = systemcommand.h; sourceTree = "<group>"; };
+ 37B73CCE1004F5E0008C4B41 /* systemcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = systemcommand.cpp; sourceTree = "<group>"; };
37C1D9710F86506E0059E3F0 /* binsequencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = binsequencecommand.h; sourceTree = SOURCE_ROOT; };
37C1D9720F86506E0059E3F0 /* binsequencecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = binsequencecommand.cpp; sourceTree = SOURCE_ROOT; };
37C753CC0FB3415200DBD02E /* distancecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = distancecommand.h; sourceTree = SOURCE_ROOT; };
37D928460F21331F001D4494 /* summarycommand.cpp */,
37D9284B0F21331F001D4494 /* summarysharedcommand.h */,
37D9284A0F21331F001D4494 /* summarysharedcommand.cpp */,
+ 37B73CCD1004F5E0008C4B41 /* systemcommand.h */,
+ 37B73CCE1004F5E0008C4B41 /* systemcommand.cpp */,
211C38370F961E1F00FEE541 /* treegroupscommand.h */,
211C38360F961E1F00FEE541 /* treegroupscommand.cpp */,
7E09C5340FDA7F65002ECAE5 /* trimseqscommand.h */,
37B73C761004BEFD008C4B41 /* listseqscommand.cpp in Sources */,
37B73CA61004D89A008C4B41 /* getseqscommand.cpp in Sources */,
37B73CC01004EB38008C4B41 /* removeseqscommand.cpp in Sources */,
+ 37B73CCF1004F5E0008C4B41 /* systemcommand.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "listseqscommand.h"
#include "getseqscommand.h"
#include "removeseqscommand.h"
+#include "systemcommand.h"
/***********************************************************/
commands["list.seqs"] = "list.seqs";
commands["get.seqs"] = "get.seqs";
commands["remove.seqs"] = "get.seqs";
+ commands["system"] = "system";
commands["quit"] = "quit";
}
else if(commandName == "get.seqs") { command = new GetSeqsCommand(optionString); }
else if(commandName == "remove.seqs") { command = new RemoveSeqsCommand(optionString); }
else if(commandName == "merge.files") { command = new MergeFileCommand(optionString); }
+ else if(commandName == "system") { command = new SystemCommand(optionString); }
else { command = new NoCommand(optionString); }
return command;
--- /dev/null
+/*
+ * systemcommand.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 7/8/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "systemcommand.h"
+
+//**********************************************************************************************************************
+
+SystemCommand::SystemCommand(string option){
+ try {
+ abort = false;
+
+ //allow user to run help
+ if(option == "help") { help(); abort = true; }
+
+ else {
+ //valid paramters for this command
+ string Array[] = {"command"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+
+ OptionParser parser(option);
+ map<string,string> parameters = parser.getParameters();
+
+ ValidParameters validParameter;
+
+ //check to make sure all parameters are valid for command
+ for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
+ if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
+ }
+
+ //check for required parameters
+ command = validParameter.validFile(parameters, "command", false);
+ if (command == "not found") { mothurOut("command is a required parameter."); mothurOutEndLine(); abort = true; }
+ }
+
+ }
+ catch(exception& e) {
+ errorOut(e, "SystemCommand", "SystemCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+
+void SystemCommand::help(){
+ try {
+ mothurOut("The system command allows you to execute a system command from within mothur.\n");
+ mothurOut("The system command parameter is command and it is required.\n");
+ mothurOut("The system command should be in the following format: system(command=yourCommand).\n");
+ mothurOut("Example system(command=clear).\n");
+ mothurOut("Note: No spaces between parameter labels (i.e. command), '=' and parameters (i.e.yourCommand).\n\n");
+ }
+ catch(exception& e) {
+ errorOut(e, "SystemCommand", "help");
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
+
+int SystemCommand::execute(){
+ try {
+
+ if (abort == true) { return 0; }
+
+ system(command.c_str());
+
+ return 0;
+ }
+
+ catch(exception& e) {
+ errorOut(e, "SystemCommand", "execute");
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
--- /dev/null
+#ifndef SYSTEMCOMMAND_H
+#define SYSTEMCOMMAND_H
+
+/*
+ * systemcommand.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 7/8/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "command.hpp"
+
+
+class SystemCommand : public Command {
+
+ public:
+
+ SystemCommand(string);
+ ~SystemCommand(){};
+ int execute();
+ void help();
+
+ private:
+ string command;
+ bool abort;
+
+};
+
+#endif
+