]> SALOME platform Git repositories - modules/kernel.git/blob - src/Batch/Batch_BatchManager_Local_SH.cxx
Salome HOME
PR: merge from branch BR_auto_V310 tag mergefrom_OCC_development_for_3_2_0a2_10mar06
[modules/kernel.git] / src / Batch / Batch_BatchManager_Local_SH.cxx
1 /*
2  * BatchManager_Local_SH.cxx : 
3  *
4  * Auteur : Ivan DUTKA-MALEN - EDF R&D
5  * Mail   : mailto:ivan.dutka-malen@der.edf.fr
6  * Date   : Thu Nov  6 10:17:22 2003
7  * Projet : Salome 2
8  *
9  */
10
11 #ifdef HAVE_CONFIG_H
12 #  include <SALOMEconfig.h>
13 #endif
14
15 #include <iostream>
16 #include <fstream>
17 #include <sstream>
18 #include <cstdlib>
19 #include <sys/types.h>
20 #include <sys/wait.h>
21 #include <ctime>
22 #include <unistd.h>
23 #include <pthread.h>
24 #include <signal.h>
25 #include <errno.h>
26 #include <string.h>
27 #include "Batch_IOMutex.hxx"
28 #include "Batch_BatchManager_Local_SH.hxx"
29
30 #ifndef RM
31 #error "RM undefined. You must set RM to a valid path to a rm-like command."
32 #endif
33
34 #ifndef CP
35 #error "CP undefined. You must set CP to a valid path to a cp-like command."
36 #endif
37
38 #ifndef SH
39 #error "SH undefined. You must set SH to a valid path to a sh-like command."
40 #endif
41
42 namespace Batch {
43
44
45   // Constructeur
46   BatchManager_Local_SH::BatchManager_Local_SH(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_Local(parent, host)
47   {
48   }
49
50   // Destructeur
51   BatchManager_Local_SH::~BatchManager_Local_SH()
52   {
53   }
54
55
56   // Methode qui renvoie la commande de copie du fichier source en destination
57   string BatchManager_Local_SH::copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const
58   {
59     ostringstream copy_cmd;
60     copy_cmd << CP << " " << source << " " << destination;
61     return copy_cmd.str();
62   }
63   
64   // Methode qui renvoie la commande a executer
65   string BatchManager_Local_SH::exec_command(Parametre & param) const
66   {
67     ostringstream exec_sub_cmd;
68     exec_sub_cmd << param[EXECUTABLE];
69
70     if (param.find(ARGUMENTS) != param.end()) {
71       Versatile V = param[ARGUMENTS];
72       for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) {
73         StringType argt = * static_cast<StringType *>(*it);
74         string     arg  = argt;
75         exec_sub_cmd << " " << arg;
76       }
77     }
78
79     param[ARGUMENTS]  = "-c";
80     param[ARGUMENTS] += exec_sub_cmd.str();
81
82     return SH;
83   }
84
85   // Methode qui renvoie la commande d'effacement du fichier
86   string BatchManager_Local_SH::remove_command(const string & host_destination, const string & destination) const
87   {
88     ostringstream remove_cmd;
89     remove_cmd << RM << " " << destination;
90     return remove_cmd.str();
91   }
92   
93 }