source: trunk/FACT++/src/sendcommand.cc@ 10663

Last change on this file since 10663 was 10624, checked in by Daniela Dorner, 14 years ago
implemented --dbname and its evaluation for the scheduler
File size: 2.4 KB
Line 
1#include <iostream>
2#include <dic.hxx>
3
4#include "Configuration.h"
5
6using namespace std;
7
8
9
10void SetupConfiguration(Configuration &conf)
11{
12 const string n = conf.GetName()+".log";
13
14 //po::options_description config("Program options");
15 po::options_description config("Configuration");
16 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")
22 ;
23
24 conf.AddEnv("dns", "DIM_DNS_NODE");
25
26 conf.AddOptions(config);
27}
28
29
30
31int main(int argc, const char* argv[])
32{
33 Configuration conf(argv[0]);
34 SetupConfiguration(conf);
35
36 po::variables_map vm;
37 try
38 {
39 vm = conf.Parse(argc, argv);
40 }
41 catch (std::exception &e)
42 {
43#if BOOST_VERSION > 104000
44 po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e);
45 if (MO)
46 cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl;
47 else
48#endif
49 cout << "Error: " << e.what() << endl;
50 cout << endl;
51
52 return -1;
53 }
54
55 const char* dbname;
56 if (conf.Has("dbname"))
57 dbname = conf.Get<string>("dbname").c_str();
58 else
59 {
60 cout << "Please provide which database you want to use for scheduling using --dbname=<dbname>." << endl;
61 return -1;
62 }
63
64
65 if (conf.HasHelp() || conf.HasPrint())
66 return -1;
67
68 // To allow overwriting of DIM_DNS_NODE set 0 to 1
69 setenv("DIM_DNS_NODE", conf.Get<string>("dns").c_str(), 1);
70
71//int main ()
72//{
73
74 int value;
75
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
89}
Note: See TracBrowser for help on using the repository browser.