2 * BatchManager_Local_RSH.cxx :
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
12 # include <SALOMEconfig.h>
19 #include <sys/types.h>
27 #include "Batch_IOMutex.hxx"
28 #include "Batch_BatchManager_Local_RSH.hxx"
31 #error "RM undefined. You must set RM to a valid path to a rm-like command."
35 #error "RCP undefined. You must set RCP to a valid path to a rcp-like command."
39 #error "RSH undefined. You must set RSH to a valid path to a rsh-like command."
46 BatchManager_Local_RSH::BatchManager_Local_RSH(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_Local(parent, host)
51 BatchManager_Local_RSH::~BatchManager_Local_RSH()
56 // Methode abstraite qui renvoie la commande de copie du fichier source en destination
57 string BatchManager_Local_RSH::copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const
59 ostringstream fullsource;
60 if (host_source.size() == 0) {
61 fullsource << "localhost:";
63 fullsource << host_source << ":";
67 ostringstream fulldestination;
68 if (host_destination.size() == 0) {
69 fulldestination << "localhost:";
71 fulldestination << host_destination << ":";
73 fulldestination << destination;
75 ostringstream copy_cmd;
76 copy_cmd << RCP << " " << fullsource.str() << " " << fulldestination.str();
77 return copy_cmd.str();
80 // Methode abstraite qui renvoie la commande a executer
81 string BatchManager_Local_RSH::exec_command(Parametre & param) const
83 ostringstream exec_sub_cmd;
84 exec_sub_cmd << param[EXECUTABLE];
86 if (param.find(ARGUMENTS) != param.end()) {
87 Versatile V = param[ARGUMENTS];
88 for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) {
89 StringType argt = * static_cast<StringType *>(*it);
91 exec_sub_cmd << " " << arg;
96 Versatile new_arguments;
97 new_arguments.setMaxSize(0);
98 new_arguments = string(param[EXECUTIONHOST]);
101 if (param.find(USER) != param.end()) {
102 new_arguments += "-l";
103 new_arguments += string(param[USER]);
106 new_arguments += exec_sub_cmd.str();
108 param[ARGUMENTS] = new_arguments;
110 // Sous Linux on est oblige de modifier ces deux parametres pour faire fonctionner la commande rsh
111 param[EXECUTABLE] = RSH;
117 // Methode qui renvoie la commande d'effacement du fichier
118 string BatchManager_Local_RSH::remove_command(const string & host_destination, const string & destination) const
120 string host = (host_destination.size()) ? host_destination : "localhost:";
122 ostringstream remove_cmd;
123 remove_cmd << RSH << " " << host << " \"" << RM << " " << destination << "\"";
124 return remove_cmd.str();