From 2219681ee7ddb1d0eb6d31cd219462686e58f42b Mon Sep 17 00:00:00 2001 From: barate Date: Thu, 7 May 2009 14:05:36 +0000 Subject: [PATCH] Added Windows implementation for local submission based on SSH and PBS emulation (with PuTTY) --- CMakeModules/FindLocal.cmake | 6 +- INSTALL | 27 +++ src/Core/Batch_BatchManager_eClient.cxx | 200 +++++++++++++++++---- src/Core/Batch_BatchManager_eClient.hxx | 5 +- src/LSF/Batch_BatchManager_eLSF.cxx | 2 +- src/Local/Batch_BatchManager_Local.cxx | 5 +- src/Local/Batch_BatchManager_Local_RSH.cxx | 1 - src/Local/Batch_BatchManager_Local_SSH.cxx | 26 ++- src/Local/Test/CMakeLists.txt | 2 + src/Local/Test/Test_Local_SSH.cxx | 3 +- src/Local/Test/Test_Local_config.h.in | 1 + src/PBS/Batch_BatchManager_ePBS.cxx | 124 ++++++------- src/PBS/Test/Test_ePBS.cxx | 2 +- src/SGE/Batch_BatchManager_eSGE.cxx | 2 +- 14 files changed, 288 insertions(+), 118 deletions(-) diff --git a/CMakeModules/FindLocal.cmake b/CMakeModules/FindLocal.cmake index 9967f33..a16ce90 100644 --- a/CMakeModules/FindLocal.cmake +++ b/CMakeModules/FindLocal.cmake @@ -21,7 +21,7 @@ # MACRO(FIND_LOCAL_COMMAND VAR COMMAND) - FIND_PROGRAM(${VAR} ${COMMAND}) + FIND_PROGRAM(${VAR} NAMES ${COMMAND} ${ARGN}) IF (${VAR}) MESSAGE(STATUS "${COMMAND} found : ${${VAR}}") ELSE (${VAR}) @@ -37,5 +37,5 @@ FIND_LOCAL_COMMAND(SH sh) FIND_LOCAL_COMMAND(CP cp) FIND_LOCAL_COMMAND(RSH rsh) FIND_LOCAL_COMMAND(RCP rcp) -FIND_LOCAL_COMMAND(SSH ssh) -FIND_LOCAL_COMMAND(SCP scp) +FIND_LOCAL_COMMAND(SSH ssh plink) +FIND_LOCAL_COMMAND(SCP scp pscp) diff --git a/INSTALL b/INSTALL index d0a4c60..faefda4 100644 --- a/INSTALL +++ b/INSTALL @@ -132,3 +132,30 @@ directory and type: $ cmake ../libBatch-X.X.X (X's are version numbers) $ make package (for binary package) $ make package_source (for source package) + + +5. Note for the users of Microsoft Windows operating system + + +The support for this library on Windows operating system is still partial and +experimental. Some features are not and will not be implemented for this +system. Nevertheless it is possible to compile the library and launch some +batch jobs from a computer running Windows. This section only gives some +guidelines, without any warranty, to install libBatch on Windows. + +First you will need to install a library providing pthread implementation. For +this we tested Pthreads-win32 (http://sourceware.org/pthreads-win32/) but other +implementations may exist. + +You will also need a compiler for Win32 platform. We tested MinGW and MSYS +utilities (http://www.mingw.org/) but another compiler might also work. + +Then you will have to install and run CMake, and you should be able to compile +libBatch and run some basic examples. + +If you need to use SSH protocol to submit jobs to your cluster, you will need +a SSH implementation for Windows operating system. PuTTY is a good choice for +that (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html). Once +installed, add the path to your PuTTY installation in the PATH environment +variable and run CMake. The build system will detect it and the libBatch will +use it for SSH-based transfers with the server. diff --git a/src/Core/Batch_BatchManager_eClient.cxx b/src/Core/Batch_BatchManager_eClient.cxx index 1bbabf8..c0a8ae4 100644 --- a/src/Core/Batch_BatchManager_eClient.cxx +++ b/src/Core/Batch_BatchManager_eClient.cxx @@ -31,14 +31,16 @@ #include "Batch_BatchManager_eClient.hxx" #include "Batch_RunTimeException.hxx" -#include "Batch_NotYetImplementedException.hxx" #include #include #include -#include -#include -#include + +#ifdef WIN32 +#include +#endif + +#include "Batch_config.h" using namespace std; @@ -66,29 +68,31 @@ namespace Batch { Parametre params = job.getParametre(); Versatile V = params[INFILE]; Versatile::iterator Vit; - string command; - string copy_command; _username = string(params[USER]); + string command = "\""; + string copy_command = "\""; + // Test protocol - if( _protocol == "rsh" ) - copy_command = "rcp "; - else if( _protocol == "ssh" ) - copy_command = "scp "; - else + if( _protocol == "rsh" ) { + command += RSH; + copy_command += RCP; + } else if( _protocol == "ssh" ) { + command += SSH; + copy_command += SCP; + } else throw EmulationException("Unknown protocol : only rsh and ssh are known !"); + command += "\" "; + copy_command += "\" "; + // First step : creating batch tmp files directory - command = _protocol; - command += " "; if(_username != ""){ - command += _username; - command += "@"; + command += _username + "@"; } command += _hostname; - command += " \"mkdir -p "; + command += " mkdir -p "; command += string(params[TMPDIR]); - command += "\"" ; cerr << command.c_str() << endl; status = system(command.c_str()); if(status) { @@ -122,6 +126,35 @@ namespace Batch { ex_mess += oss.str(); throw EmulationException(ex_mess.c_str()); } + +#ifdef WIN32 + // On Windows, we make the remote file executable afterward because pscp does not preserve + // access permissions on files + command = "\""; + if( _protocol == "rsh" ) { + command += RSH; + } else if( _protocol == "ssh" ) { + command += SSH; + } else + throw EmulationException("Unknown protocol : only rsh and ssh are known !"); + + command += "\" "; + if(_username != ""){ + command += _username + "@"; + } + command += _hostname; + command += " chmod u+x "; + command += string(params[TMPDIR]) + "/" + string(params[EXECUTABLE]); + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) { + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw EmulationException(ex_mess.c_str()); + } +#endif } // Third step : copy filesToExportList into @@ -154,7 +187,6 @@ namespace Batch { void BatchManager_eClient::importOutputFiles( const Job & job, const string directory ) throw(EmulationException) { - string command; int status; Parametre params = job.getParametre(); @@ -164,12 +196,18 @@ namespace Batch { for(Vit=V.begin(); Vit!=V.end(); Vit++) { CoupleType cpt = *static_cast< CoupleType * >(*Vit); Couple outputFile = cpt; - if( _protocol == "rsh" ) - command = "rcp "; - else if( _protocol == "ssh" ) - command = "scp "; - else - throw EmulationException("Unknown protocol"); + + string command = "\""; + + // Test protocol + if( _protocol == "rsh" ) { + command += RCP; + } else if( _protocol == "ssh" ) { + command += SCP; + } else + throw EmulationException("Unknown protocol : only rsh and ssh are known !"); + + command += "\" "; if (_username != ""){ command += _username; @@ -219,36 +257,122 @@ namespace Batch { } } + /** + * This method generates a temporary file name with the pattern "/-XXXXXX" where + * is the directory for temporary files (see BatchManager_eClient::getTmpDir()) and the + * X's are replaced by random characters. Note that this method is less secure than + * BatchManager_eClient::createAndOpenTemporaryFile, so use the latter whenever possible. + * \param prefix the prefix to use for the temporary file. + * \return a name usable for a temporary file. + */ + string BatchManager_eClient::generateTemporaryFileName(const string & prefix) + { + string fileName = getTmpDir() + "/" + prefix + "-XXXXXX"; + char randstr[7]; + + do { + sprintf(randstr, "%06d", rand() % 1000000); + fileName.replace(fileName.size()-6, 6, randstr); + } while (access(fileName.c_str(), F_OK) == 0); + + return fileName; + } + /** * This method creates a temporary file and opens an output stream to write into this file. - * The file is created with the pattern "/tmp/batch_XXXXXX" where the X's are replaced by random + * The file is created with the pattern "/-XXXXXX" where is the directory + * for temporary files (see BatchManager_eClient::getTmpDir()) and the X's are replaced by random * characters. The caller is responsible for closing and deleting the file when it is no more used. + * \param prefix the prefix to use for the temporary file. * \param outputStream an output stream that will be opened for writing in the temporary file. If * the stream is already open, it will be closed first. * \return the name of the created file. */ - string BatchManager_eClient::createAndOpenTemporaryFile(ofstream & outputStream) const + string BatchManager_eClient::createAndOpenTemporaryFile(const string & prefix, ofstream & outputStream) { - string fileName; + if (outputStream.is_open()) + outputStream.close(); + #ifdef WIN32 - throw NotYetImplementedException("Temporary file creation in Batch library has not been ported to Windows yet"); + + string fileName = generateTemporaryFileName(prefix); + outputStream.open(fileName.c_str()); + #else - char * tmpFileName = strdup("/tmp/batch_XXXXXX"); - int fd = mkstemp(tmpFileName); + + string fileName = getTmpDir() + "/" + prefix + "-XXXXXX"; + char buf[fileName.size()+1]; + fileName.copy(buf, fileName.size()); + buf[fileName.size()] = '\0'; + + int fd = mkstemp(buf); if (fd == -1) - { - throw RunTimeException("Can't create temporary file"); - } + throw RunTimeException(string("Can't create temporary file ") + fileName); + fileName = buf; - if (outputStream.is_open()) - outputStream.close(); - outputStream.open(tmpFileName); + outputStream.open(fileName.c_str()); close(fd); // Close the file descriptor so that the file is not opened twice - fileName = tmpFileName; - delete[] tmpFileName; #endif + + if (outputStream.fail()) + throw RunTimeException(string("Can't open temporary file ") + fileName); + return fileName; } + /** + * This method finds the name of the directory to use for temporary files in libBatch. This name + * is /libBatch--XXXXXX. is found by looking for environment + * variables TEMP, TMP, TEMPDIR, TMPDIR, and defaults to "/tmp" if none of them is defined. + * is found by looking for environment variables USER and USERNAME, and defaults to + * "unknown". XXXXXX represents random characters. The directory name is generated only once for + * each BatchManager_eClient instance, and the directory is created at this moment. Subsequent + * calls will always return the same path and the existence of the directory will not be + * rechecked. + * \return the name of the directory to use for temporary files. + */ + const std::string & BatchManager_eClient::getTmpDir() + { + if (tmpDirName.empty()) { + char * baseDir = getenv("TEMP"); + if (baseDir == NULL) baseDir = getenv("TMP"); + if (baseDir == NULL) baseDir = getenv("TEMPDIR"); + if (baseDir == NULL) baseDir = getenv("TMPDIR"); + if (baseDir == NULL) baseDir = "/tmp"; + + char * userName = getenv("USER"); + if (userName == NULL) userName = getenv("USERNAME"); + if (userName == NULL) userName = "unknown"; + + string baseName = string(baseDir) + "/libBatch-" + userName + "-XXXXXX"; + srand(time(NULL)); + +#ifdef WIN32 + + char randstr[7]; + do { + sprintf(randstr, "%06d", rand() % 1000000); + baseName.replace(baseName.size()-6, 6, randstr); + } while (access(baseName.c_str(), F_OK) == 0); + if (_mkdir(baseName.c_str()) != 0) + throw RunTimeException(string("Can't create temporary directory ") + baseName); + tmpDirName = baseName; + +#else + + char buf[baseName.size()+1]; + baseName.copy(buf, baseName.size()); + buf[baseName.size()] = '\0'; + if (mkdtemp(buf) == NULL) + throw RunTimeException(string("Can't create temporary directory ") + baseName); + tmpDirName = buf; + +#endif + + } + + return tmpDirName; + } + } diff --git a/src/Core/Batch_BatchManager_eClient.hxx b/src/Core/Batch_BatchManager_eClient.hxx index 938e8ec..a225492 100644 --- a/src/Core/Batch_BatchManager_eClient.hxx +++ b/src/Core/Batch_BatchManager_eClient.hxx @@ -57,11 +57,14 @@ namespace Batch { std::string _username; // username to access _hostname MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script - std::string createAndOpenTemporaryFile(std::ofstream & outputStream) const; + std::string generateTemporaryFileName(const std::string & prefix); + std::string createAndOpenTemporaryFile(const std::string & prefix, std::ofstream & outputStream); MpiImpl* FactoryMpiImpl(std::string mpiImpl) throw(EmulationException); void exportInputFiles(const Job & job); + const std::string & getTmpDir(); private: + std::string tmpDirName; // Path to the directory for temporary files }; diff --git a/src/LSF/Batch_BatchManager_eLSF.cxx b/src/LSF/Batch_BatchManager_eLSF.cxx index e48690c..14b5a2b 100644 --- a/src/LSF/Batch_BatchManager_eLSF.cxx +++ b/src/LSF/Batch_BatchManager_eLSF.cxx @@ -277,7 +277,7 @@ namespace Batch { } ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); + std::string TmpFileName = createAndOpenTemporaryFile("LSF-script", tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl ; if (queue != "") diff --git a/src/Local/Batch_BatchManager_Local.cxx b/src/Local/Batch_BatchManager_Local.cxx index 77241a9..409e5ed 100644 --- a/src/Local/Batch_BatchManager_Local.cxx +++ b/src/Local/Batch_BatchManager_Local.cxx @@ -849,8 +849,6 @@ namespace Batch { throw RunTimeException("Parameter \"EXECUTABLE\" is mandatory for local batch submission"); } - string name = (param.find(NAME) != param.end()) ? param[NAME] : param[EXECUTABLE]; - if (param.find(ARGUMENTS) != param.end()) { Versatile V = param[ARGUMENTS]; @@ -860,7 +858,6 @@ namespace Batch { } } - UNDER_LOCK( cout << "*** exec_command = " << exec_command << endl ); @@ -900,7 +897,7 @@ namespace Batch { // launch the new process BOOL res = CreateProcess(NULL, buffer, NULL, NULL, FALSE, - 0, chNewEnv, NULL, &si, &pi); + DETACHED_PROCESS, chNewEnv, NULL, &si, &pi); if (!res) throw RunTimeException("Error while creating new process"); diff --git a/src/Local/Batch_BatchManager_Local_RSH.cxx b/src/Local/Batch_BatchManager_Local_RSH.cxx index 54cae55..0ca4e99 100644 --- a/src/Local/Batch_BatchManager_Local_RSH.cxx +++ b/src/Local/Batch_BatchManager_Local_RSH.cxx @@ -132,7 +132,6 @@ namespace Batch { } } - Versatile new_arguments; new_arguments.setMaxSize(0); new_arguments = string(param[EXECUTIONHOST]); diff --git a/src/Local/Batch_BatchManager_Local_SSH.cxx b/src/Local/Batch_BatchManager_Local_SSH.cxx index f829d60..76af411 100644 --- a/src/Local/Batch_BatchManager_Local_SSH.cxx +++ b/src/Local/Batch_BatchManager_Local_SSH.cxx @@ -91,12 +91,18 @@ namespace Batch { { ostringstream fullsource; if (host_source.size() != 0) { + if (user_source.size() != 0) { + fullsource << user_source << "@"; + } fullsource << host_source << ":"; } fullsource << source; ostringstream fulldestination; if (host_destination.size() != 0) { + if (user_destination.size() != 0) { + fulldestination << user_destination << "@"; + } fulldestination << host_destination << ":"; } fulldestination << destination; @@ -104,7 +110,7 @@ namespace Batch { ostringstream copy_cmd; // Option -p is used to keep the same permissions for the destination file (particularly useful to keep scripts // executable when copying them) - copy_cmd << SCP << " -p " << fullsource.str() << " " << fulldestination.str(); + copy_cmd << "\"" << SCP << "\" -p " << fullsource.str() << " " << fulldestination.str(); return copy_cmd.str(); } @@ -112,8 +118,10 @@ namespace Batch { string BatchManager_Local_SSH::exec_command(Parametre & param) const { ostringstream exec_sub_cmd; - exec_sub_cmd << "cd " << param[WORKDIR] << ";"; - exec_sub_cmd << param[EXECUTABLE]; +#ifdef WIN32 + exec_sub_cmd << "\""; +#endif + exec_sub_cmd << "cd " << param[WORKDIR] << " && " << param[EXECUTABLE]; if (param.find(ARGUMENTS) != param.end()) { Versatile V = param[ARGUMENTS]; @@ -123,6 +131,9 @@ namespace Batch { exec_sub_cmd << " " << arg; } } +#ifdef WIN32 + exec_sub_cmd << "\""; +#endif Versatile new_arguments; @@ -151,10 +162,15 @@ namespace Batch { const std::string & host_destination, const std::string & destination) const { - string host = (host_destination.size()) ? host_destination : "localhost:"; + string fulldestination = (host_destination.size()) ? host_destination : "localhost"; + if (user_destination.size() != 0) { + fulldestination += " -l " + user_destination; + } + // We consider here that the remote system is UNIX-like and has a "rm" command. Using the + // RM macro would be pointless here since the remote system is different from the local one. ostringstream remove_cmd; - remove_cmd << SSH << " " << host << " \"" << RM << " " << destination << "\""; + remove_cmd << "\"" << SSH << "\" " << fulldestination << " \"rm " << destination << "\""; return remove_cmd.str(); } } diff --git a/src/Local/Test/CMakeLists.txt b/src/Local/Test/CMakeLists.txt index 548a88e..72a3322 100644 --- a/src/Local/Test/CMakeLists.txt +++ b/src/Local/Test/CMakeLists.txt @@ -33,6 +33,8 @@ SET (TEST_LOCAL_RSH_WORK_DIR "/tmp" CACHE STRING SET (TEST_LOCAL_SSH_EXECUTION_HOST "localhost" CACHE STRING "Execution host for SSH Batch test (only necessary for test target)") +SET (TEST_LOCAL_SSH_USER $ENV{USER} CACHE STRING + "User name on the execution host for SSH Batch test (only necessary for test target)") SET (TEST_LOCAL_SSH_WORK_DIR "/tmp" CACHE STRING "Work directory for SSH Batch test (only necessary for test target)") diff --git a/src/Local/Test/Test_Local_SSH.cxx b/src/Local/Test/Test_Local_SSH.cxx index 0284204..db28d9c 100644 --- a/src/Local/Test/Test_Local_SSH.cxx +++ b/src/Local/Test/Test_Local_SSH.cxx @@ -54,7 +54,7 @@ int main(int argc, char** argv) Job job; // ... and its parameters ... Parametre p; - p["EXECUTABLE"] = "./copied-test-script.sh"; + p["EXECUTABLE"] = "source copied-test-script.sh"; p["NAME"] = "Test_Local_SSH"; p["WORKDIR"] = TEST_LOCAL_SSH_WORK_DIR; p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); @@ -62,6 +62,7 @@ int main(int argc, char** argv) p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); p["EXECUTIONHOST"] = TEST_LOCAL_SSH_EXECUTION_HOST; + p["USER"] = TEST_LOCAL_SSH_USER; job.setParametre(p); // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication) Environnement e; diff --git a/src/Local/Test/Test_Local_config.h.in b/src/Local/Test/Test_Local_config.h.in index f584f72..c1f9d6d 100644 --- a/src/Local/Test/Test_Local_config.h.in +++ b/src/Local/Test/Test_Local_config.h.in @@ -27,6 +27,7 @@ #define TEST_LOCAL_RSH_WORK_DIR "${TEST_LOCAL_RSH_WORK_DIR}" #define TEST_LOCAL_SSH_EXECUTION_HOST "${TEST_LOCAL_SSH_EXECUTION_HOST}" +#define TEST_LOCAL_SSH_USER "${TEST_LOCAL_SSH_USER}" #define TEST_LOCAL_SSH_WORK_DIR "${TEST_LOCAL_SSH_WORK_DIR}" #ifdef WIN32 diff --git a/src/PBS/Batch_BatchManager_ePBS.cxx b/src/PBS/Batch_BatchManager_ePBS.cxx index 9588971..d965897 100644 --- a/src/PBS/Batch_BatchManager_ePBS.cxx +++ b/src/PBS/Batch_BatchManager_ePBS.cxx @@ -33,16 +33,10 @@ #include #include #include -#include -#include +#include #include "Batch_BatchManager_ePBS.hxx" -#ifdef WIN32 -# include -# include -#else -# include -#endif +#include "Batch_config.h" using namespace std; @@ -64,9 +58,6 @@ namespace Batch { // Methode pour le controle des jobs : soumet un job au gestionnaire const JobId BatchManager_ePBS::submitJob(const Job & job) { -#ifdef WIN32 - throw NotYetImplementedException("PBS emulation not supported on Windows platform yet"); -#else int status; Parametre params = job.getParametre(); const std::string dirForTmpFiles = params[TMPDIR]; @@ -81,36 +72,39 @@ namespace Batch { // build batch script for job buildBatchScript(job); - // create log dir (local) and define name of log file - string logDir = "/tmp/logs/"; - mkdir(logDir.c_str(), S_IRWXU); - logDir += getenv("USER"); - mkdir(logDir.c_str(), S_IRWXU); - string logFile = logDir + "/batchSalome_"; - srand ( time(NULL) ); - int ir = rand(); - ostringstream oss; - oss << ir; - logFile += oss.str(); - logFile += ".log"; - - string command; + // define name of log file (local) + string logFile = generateTemporaryFileName("PBS-submitlog"); // define command to submit batch - command = _protocol; - command += " "; + string command = "\""; + + // Test protocol + if( _protocol == "rsh" ) + command += RSH; + else if( _protocol == "ssh" ) + command += SSH; + else + throw EmulationException("Unknown protocol : only rsh and ssh are known !"); + + command += "\" "; if(_username != ""){ - command += _username; - command += "@"; + command += _username + "@"; } - command += _hostname; - command += " \"cd " ; + command += _hostname + " "; +#ifndef WIN32 + command += "\""; +#endif + command += "cd " ; command += dirForTmpFiles ; command += "; qsub " ; command += fileNameToExecute ; - command += "_Batch.sh\" > "; + command += "_Batch.sh"; +#ifndef WIN32 + command += "\""; +#endif + command += " > "; command += logFile; cerr << command.c_str() << endl; status = system(command.c_str()); @@ -133,7 +127,6 @@ namespace Batch { JobId id(this, strjob); return id; -#endif //WIN32 } // Methode pour le controle des jobs : retire un job du gestionnaire @@ -204,35 +197,39 @@ namespace Batch { istringstream iss(jobid.getReference()); iss >> id; - // define name of log file - string logFile="/tmp/logs/"; - logFile += getenv("USER"); - logFile += "/batchSalome_"; + // define name of log file (local) + string logFile = generateTemporaryFileName(string("PBS-querylog-id") + jobid.getReference()); - ostringstream oss; - oss << this << "_" << id; - logFile += oss.str(); - logFile += ".log"; + // define command to query batch + string command = "\""; - string command; - int status; + // Test protocol + if( _protocol == "rsh" ) + command += RSH; + else if( _protocol == "ssh" ) + command += SSH; + else + throw EmulationException("Unknown protocol : only rsh and ssh are known !"); - // define command to submit batch - command = _protocol; - command += " "; + command += "\" "; if (_username != ""){ - command += _username; - command += "@"; + command += _username + "@"; } - command += _hostname; - command += " \"qstat -f " ; + command += _hostname + " "; +#ifndef WIN32 + command += "\""; +#endif + command += "qstat -f " ; command += iss.str(); - command += "\" > "; +#ifndef WIN32 + command += "\""; +#endif + command += " > "; command += logFile; cerr << command.c_str() << endl; - status = system(command.c_str()); + int status = system(command.c_str()); if(status && status != 153 && status != 256*153) throw EmulationException("Error of connection on remote host"); @@ -248,7 +245,6 @@ namespace Batch { void BatchManager_ePBS::buildBatchScript(const Job & job) { -#ifndef WIN32 //TODO: need for porting on Windows int status; Parametre params = job.getParametre(); Environnement env = job.getEnvironnement(); @@ -279,7 +275,7 @@ namespace Batch { } ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); + std::string TmpFileName = createAndOpenTemporaryFile("PBS-script", tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl; if (queue != "") @@ -318,13 +314,18 @@ namespace Batch { TmpFileName.c_str(), 0x1ED); cerr << TmpFileName.c_str() << endl; - string command; - if( _protocol == "rsh" ) - command = "rcp "; - else if( _protocol == "ssh" ) - command = "scp "; - else - throw EmulationException("Unknown protocol"); + string command = "\""; + + // Test protocol + if( _protocol == "rsh" ) { + command += RCP; + } else if( _protocol == "ssh" ) { + command += SCP; + } else + throw EmulationException("Unknown protocol : only rsh and ssh are known !"); + + command += "\" "; + command += TmpFileName; command += " "; if(_username != ""){ @@ -343,7 +344,6 @@ namespace Batch { throw EmulationException("Error of connection on remote host"); remove(TmpFileName.c_str()); -#endif } } diff --git a/src/PBS/Test/Test_ePBS.cxx b/src/PBS/Test/Test_ePBS.cxx index 75d6d5f..46de101 100644 --- a/src/PBS/Test/Test_ePBS.cxx +++ b/src/PBS/Test/Test_ePBS.cxx @@ -92,7 +92,7 @@ int main(int argc, char** argv) // Wait for the end of the job string state = "Undefined"; - for (int i=0 ; i<10 && state != "U"; i++) { + for (int i=0 ; i<60 && state != "U"; i++) { sleep(2); JobInfo jinfo = jobid.queryJob(); state = jinfo.getParametre()["STATE"].str(); diff --git a/src/SGE/Batch_BatchManager_eSGE.cxx b/src/SGE/Batch_BatchManager_eSGE.cxx index cb4f960..1e1634d 100644 --- a/src/SGE/Batch_BatchManager_eSGE.cxx +++ b/src/SGE/Batch_BatchManager_eSGE.cxx @@ -264,7 +264,7 @@ namespace Batch { } ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); + std::string TmpFileName = createAndOpenTemporaryFile("SGE-script", tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl; if (queue != "") -- 2.39.2