]> git.donarmstrong.com Git - mothur.git/blob - systemcommand.cpp
added sorted option to get.rabund command
[mothur.git] / systemcommand.cpp
1 /*
2  *  systemcommand.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 7/8/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "systemcommand.h"
11
12 //**********************************************************************************************************************
13
14 SystemCommand::SystemCommand(string option){
15         try {
16                 abort = false;
17                 
18                 //allow user to run help
19                 if(option == "help") { help(); abort = true; }
20                 
21                 else {
22                         if (option == "") { mothurOut("You must enter a command to run."); mothurOutEndLine(); abort = true; }
23                         else { command = option; }
24                 }       
25
26         }
27         catch(exception& e) {
28                 errorOut(e, "SystemCommand", "SystemCommand");
29                 exit(1);
30         }
31 }
32 //**********************************************************************************************************************
33
34 void SystemCommand::help(){
35         try {
36                 mothurOut("The system command allows you to execute a system command from within mothur.\n");
37                 mothurOut("The system has no parameters.\n");
38                 mothurOut("The system command should be in the following format: system(yourCommand).\n");
39                 mothurOut("Example system(clear).\n");
40         }
41         catch(exception& e) {
42                 errorOut(e, "SystemCommand", "help");
43                 exit(1);
44         }
45 }
46
47 //**********************************************************************************************************************
48
49 int SystemCommand::execute(){
50         try {
51                 
52                 if (abort == true) { return 0; }
53                 
54                 system(command.c_str());
55                 
56                 return 0;               
57         }
58
59         catch(exception& e) {
60                 errorOut(e, "SystemCommand", "execute");
61                 exit(1);
62         }
63 }
64
65 //**********************************************************************************************************************