Changeset 10670 for trunk/FACT++
- Timestamp:
- 05/11/11 19:04:19 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/sendcommand.cc
r10624 r10670 2 2 #include <dic.hxx> 3 3 4 #include "FACT.h" 5 #include "Dim.h" 4 6 #include "Configuration.h" 5 7 6 8 using namespace std; 7 9 8 9 10 10 void SetupConfiguration(Configuration &conf) 11 11 { 12 const string n = conf.GetName()+".log";13 14 //po::options_description config("Program options");15 12 po::options_description config("Configuration"); 16 13 config.add_options() 17 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)") 18 ("log,l", var<string>(n), "Write log-file") 19 //("no-dim,d", po_switch(), "Disable dim services") 20 //("console,c", var<int>(), "Use console (0=shell, 1=simple buffered, X=simple unbuffered)") 21 ("dbname", var<string>(), "database name for scheduling preview") 14 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)") 15 ("schedule-database", var<string>(), "Database name for scheduling preview") 22 16 ; 23 17 18 po::positional_options_description p; 19 p.add("schedule-database", 1); // The first positional options 20 24 21 conf.AddEnv("dns", "DIM_DNS_NODE"); 25 26 22 conf.AddOptions(config); 23 conf.SetArgumentPositions(p); 27 24 } 28 25 26 void PrintUsage() 27 { 28 cout << 29 "The triggerschedule triggers the scheduler.\n" 30 "\n" 31 "The default is that the program is started without user intercation. " 32 "All actions are supposed to arrive as DimCommands. Using the -c " 33 "option, a local shell can be initialized. With h or help a short " 34 "help message about the usuage can be brought to the screen.\n" 35 "\n" 36 "Usage: triggerschedule [-c type] [OPTIONS] <schedule-database>\n" 37 " or: triggerschedule [OPTIONS] <schedule-database>\n"; 38 cout << endl; 39 } 29 40 41 void PrintHelp() 42 { 43 cout << 44 "\n" 45 "The method sendCommand(...) will wait for the command to " 46 "be actualy sent to the server and return a completion code " 47 "of:\n" 48 " 1 - if it was successfully sent.\n" 49 " 0 - if it couldn't be delivered.\n " 50 << endl; 51 /* Additional help text which is printed after the configuration 52 options goes here */ 53 } 30 54 31 55 int main(int argc, const char* argv[]) 32 56 { 33 57 Configuration conf(argv[0]); 58 conf.SetPrintUsage(PrintUsage); 34 59 SetupConfiguration(conf); 35 60 … … 53 78 } 54 79 55 const char* dbname;56 if (conf.Has("dbname"))57 dbname = conf.Get<string>("dbname").c_str(); 58 else80 if (conf.HasPrint()) 81 return -1; 82 83 if (conf.HasVersion()) 59 84 { 60 cout << "Please provide which database you want to use for scheduling using --dbname=<dbname>." << endl;85 FACT::PrintVersion(argv[0]); 61 86 return -1; 62 87 } 63 88 89 if (conf.HasHelp()) 90 { 91 PrintHelp(); 92 return -1; 93 } 64 94 65 if (conf.HasHelp() || conf.HasPrint()) 95 if (!conf.Has("schedule-database")) 96 { 97 cout << "Please provide which database you want to use for scheduling using --schedule-database=<dbname>." << endl; 66 98 return -1; 99 } 67 100 68 // To allow overwriting of DIM_DNS_NODE set 0 to 1 69 setenv("DIM_DNS_NODE", conf.Get<string>("dns").c_str(), 1); 101 const char* dbname = conf.Get<string>("schedule-database").c_str(); 70 102 71 //int main () 72 //{ 103 Dim::Setup(conf.Get<string>("dns")); 73 104 74 int value; 105 const int rc = DimClient::sendCommand("SCHEDULER/SCHEDULE", dbname); 106 if (!rc) 107 cerr << "Sending failed!" << endl; 108 else 109 cout << "Command issued successfully." << endl; 75 110 76 value = DimClient::sendCommand("SCHEDULER/SCHEDULE", dbname); 77 //value = DimClient::sendCommand("SCHEDULER/SCHEDULE", NULL, 0); 78 79 cout << "\n"; 80 cout << " The method sendCommand(...) will wait for the command to be actualy sent to the Server and return a completion code of : " << endl; 81 cout << " 1 - if it was successfully sent " << endl; 82 cout << " 0 - if it couldn't be delivered. " << endl; 83 84 cout << "\n"; 85 cout << " The completion code is now: " << value << endl; 86 87 return 0; 88 111 return rc; 89 112 }
Note:
See TracChangeset
for help on using the changeset viewer.