-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include <iostream>
#include <fstream>
-#include "Batch_Constants.hxx"
-#include "Batch_Job.hxx"
-#include "Batch_BatchManagerCatalog.hxx"
-#include "Batch_FactBatchManager.hxx"
-#include "Batch_BatchManager.hxx"
+#include <Batch_Constants.hxx>
+#include <Batch_Job.hxx>
+#include <Batch_BatchManagerCatalog.hxx>
+#include <Batch_FactBatchManager.hxx>
+#include <Batch_BatchManager.hxx>
-#include "SimpleParser.hxx"
+#include <SimpleParser.hxx>
using namespace std;
using namespace Batch;
Job job;
// ... and its parameters ...
Parametre p;
- p[EXECUTABLE] = "source copied-test-script.sh";
+ p[EXECUTABLE] = "test-script.sh";
p[NAME] = "Test_Local_RSH";
p[WORKDIR] = workdir;
- p[INFILE] = Couple("seta.sh", "copied-seta.sh");
- p[INFILE] += Couple("setb.sh", "copied-setb.sh");
- p[INFILE] += Couple("test-script.sh", "copied-test-script.sh");
- p[OUTFILE] = Couple("result.txt", "orig-result.txt");
- p[EXECUTIONHOST] = exechost;
+ p[INFILE] = Couple("seta.sh", workdir + "/copied-seta.sh");
+ p[INFILE] += Couple("setb.sh", workdir + "/copied-setb.sh");
+ p[OUTFILE] = Couple("result.txt", workdir + "/orig-result.txt");
p[USER] = user;
job.setParametre(p);
// ... and its environment
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type Local_RSH on localhost
- FactBatchManager * fbm = c("RSH");
+ FactBatchManager * fbm = c("LOCAL");
if (fbm == NULL) {
cerr << "Can't get RSH batch manager factory" << endl;
return 1;
}
- BatchManager * bm = (*fbm)("localhost");
+ BatchManager * bm = (*fbm)(exechost.c_str(), user.c_str(), RSH);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);
// Wait for the end of the job
string state = bm->waitForJobEnd(jobid, timeout);
- if (state != FINISHED && state != FAILED) {
- cerr << "Error: Job not finished after timeout" << endl;
+ if (state == FINISHED) {
+ cout << "Job " << jobid.__repr__() << " is done" << endl;
+ bm->importOutputFiles(job, "resultdir/seconddirname");
+ } else if (state == FAILED) {
+ cerr << "Job " << jobid.__repr__() << " finished in error" << endl;
+ bm->importOutputFiles(job, "resultdir/seconddirname");
+ return 1;
+ } else {
+ cerr << "Timeout while executing job" << endl;
return 1;
}
- cout << "Job " << jobid.__repr__() << " is done" << endl;
-
} catch (GenericException e) {
cerr << "Error: " << e << endl;
return 1;
// test the result file
string exp = "c = 12";
string res;
- ifstream f("result.txt");
+ ifstream f("resultdir/seconddirname/result.txt");
getline(f, res);
f.close();