Index: trunk/MagicSoft/Mars/macros/sql/filldotrbk.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sql/filldotrbk.C	(revision 4601)
+++ trunk/MagicSoft/Mars/macros/sql/filldotrbk.C	(revision 4680)
@@ -40,4 +40,5 @@
 //   "/data/MAGIC/Period019/ccdata"             would do it for one Period
 //   "/data/MAGIC/Period019/ccdata/2004_05_17"  would do it for a single day
+//   "/data/MAGIC/Period019/ccdata/file.rbk"    would do it for a single file
 //
 // The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
@@ -54,4 +55,6 @@
 //
 // Make sure, that database and password are corretly set in the macro.
+//
+// Returns 0 in case of failure and 1 in case of success.
 //
 ///////////////////////////////////////////////////////////////////////////
@@ -102,5 +105,5 @@
 // insert the entries from this runbook file into the database
 //
-void insert(MSQLServer &serv, Bool_t dummy, TString fname)
+int insert(MSQLServer &serv, Bool_t dummy, TString fname)
 {
     //cout << endl;
@@ -111,5 +114,5 @@
     {
         cout << "Could not open file " << fname << endl;
-        return;
+        return 0;
     }
 
@@ -190,10 +193,11 @@
         TSQLResult *res = serv.Query(query);
         if (!res)
+        {
             cout << "ERROR: " << query << endl << endl;
-        else
-        {
-            delete res;
-            num++;
-        }
+            return 0;
+        }
+
+        delete res;
+        num++;
 
         entry = "";
@@ -202,4 +206,6 @@
     cout << fname(TRegexp("CC_.*.rbk", kFALSE)) << " <" << num << ">";
     cout << (dummy?" DUMMY":"") << endl;
+
+    return 1;
 }
 
@@ -208,5 +214,5 @@
 // loop over all files in this path
 //
-void filldotrbk(TString path="/data/MAGIC/Period017/ccdata", Bool_t dummy=kTRUE)
+int filldotrbk(TString path="/data/MAGIC/Period017/ccdata", Bool_t dummy=kTRUE)
 {
     MSQLServer serv("mysql://hercules:d99swMT!@localhost");
@@ -214,5 +220,5 @@
     {
         cout << "ERROR - Connection to database failed." << endl;
-        return;
+        return 0;
     }
 
@@ -225,4 +231,7 @@
     cout << endl;
 
+    if (path.EndWith(".rbk"))
+        return insert(serv, dummy, path);
+
     MDirIter Next(path, "CC_*.rbk", -1);
     while (1)
@@ -232,5 +241,8 @@
             break;
 
-        insert(serv, dummy, name);
-    }
+        if (!insert(serv, dummy, name))
+            return 0;
+    }
+
+    return 1;
 }
Index: trunk/MagicSoft/Mars/macros/sql/filldotrun.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sql/filldotrun.C	(revision 4601)
+++ trunk/MagicSoft/Mars/macros/sql/filldotrun.C	(revision 4680)
@@ -47,4 +47,5 @@
 //   "/data/MAGIC/Period019/ccdata"             would do it for one Period
 //   "/data/MAGIC/Period019/ccdata/2004_05_17"  would do it for a single day
+//   "/data/MAGIC/Period019/ccdata/file.run"    would do it for a single file
 //
 // The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
@@ -63,4 +64,6 @@
 //   root -q -l -b filldotrun.C+\(\"path\"\,kFALSE\) 2>&1 | tee filldotrun.log
 //
+// Returns 0 in case of failure and 1 in case of success.
+//
 /////////////////////////////////////////////////////////////////////////////
 #include <iostream>
@@ -152,4 +155,9 @@
 {
     ifstream fin(filename);
+    if (!fin)
+    {
+        cout << "Could not open file " << fname << endl;
+        return -1;
+    }
 
     TString strng;
@@ -160,5 +168,5 @@
         cout << "First Line: " << strng << endl;
         cout << endl;
-        return 0;
+        return -1;
     }
 
@@ -175,5 +183,5 @@
         cout << "Second Line: " << strng << endl;
         cout << endl;
-        return 0;
+        return -1;
     }
 
@@ -387,5 +395,5 @@
         {
             cout << query << " - FAILED!" << endl;
-            continue;
+            return -1;
         }
 
@@ -413,4 +421,13 @@
     cout << endl;
 
+    if (path.EndsWith(".run"))
+    {
+        cout << name(TRegexp("CC_.*.run", kFALSE)) << flush;
+        Int_t n = insert(serv, dummy, name);
+        cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
+
+        return n<0 ? 0 : 1;
+    }
+
     MDirIter Next(path, "CC_*.run", -1);
     while (1)
@@ -421,8 +438,11 @@
 
         cout << name(TRegexp("CC_.*.run", kFALSE)) << flush;
-
         Int_t n = insert(serv, dummy, name);
-
         cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
-    }
+
+        if (n<0)
+            return 0;
+    }
+
+    return 1;
 }
