1 // Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG
2 // PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 * BatchManager_Local_RSH.cxx :
22 * Auteur : Ivan DUTKA-MALEN - EDF R&D
23 * Mail : mailto:ivan.dutka-malen@der.edf.fr
24 * Date : Thu Nov 6 10:17:22 2003
30 # include <SALOMEconfig.h>
37 #include <sys/types.h>
47 #include "Batch_IOMutex.hxx"
48 #include "Batch_BatchManager_Local_RSH.hxx"
51 #error "RM undefined. You must set RM to a valid path to a rm-like command."
55 #error "RCP undefined. You must set RCP to a valid path to a rcp-like command."
59 #error "RSH undefined. You must set RSH to a valid path to a rsh-like command."
68 BatchManager_Local_RSH::BatchManager_Local_RSH(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_Local(parent, host)
73 BatchManager_Local_RSH::~BatchManager_Local_RSH()
78 // Methode abstraite qui renvoie la commande de copie du fichier source en destination
79 string BatchManager_Local_RSH::copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const
81 ostringstream fullsource;
82 if (host_source.size() == 0) {
83 fullsource << "localhost:";
85 fullsource << host_source << ":";
89 ostringstream fulldestination;
90 if (host_destination.size() == 0) {
91 fulldestination << "localhost:";
93 fulldestination << host_destination << ":";
95 fulldestination << destination;
97 ostringstream copy_cmd;
98 copy_cmd << RCP << " " << fullsource.str() << " " << fulldestination.str();
99 return copy_cmd.str();
102 // Methode abstraite qui renvoie la commande a executer
103 string BatchManager_Local_RSH::exec_command(Parametre & param) const
105 ostringstream exec_sub_cmd;
106 exec_sub_cmd << param[EXECUTABLE];
108 if (param.find(ARGUMENTS) != param.end()) {
109 Versatile V = param[ARGUMENTS];
110 for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) {
111 StringType argt = * static_cast<StringType *>(*it);
113 exec_sub_cmd << " " << arg;
118 Versatile new_arguments;
119 new_arguments.setMaxSize(0);
120 new_arguments = string(param[EXECUTIONHOST]);
123 if (param.find(USER) != param.end()) {
124 new_arguments += "-l";
125 new_arguments += string(param[USER]);
128 new_arguments += exec_sub_cmd.str();
130 param[ARGUMENTS] = new_arguments;
132 // Sous Linux on est oblige de modifier ces deux parametres pour faire fonctionner la commande rsh
133 param[EXECUTABLE] = RSH;
139 // Methode qui renvoie la commande d'effacement du fichier
140 string BatchManager_Local_RSH::remove_command(const string & host_destination, const string & destination) const
142 string host = (host_destination.size()) ? host_destination : "localhost:";
144 ostringstream remove_cmd;
145 remove_cmd << RSH << " " << host << " \"" << RM << " " << destination << "\"";
146 return remove_cmd.str();