Salome HOME
updated copyright message
[modules/kernel.git] / src / Launcher / Launcher_Job_CommandSALOME.cxx
index 59db9e09f5d00d96c2daeaf2fb22d23fd64b7493..6686ff97f8589b4c63c1dad1f00efc0054f35e7a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2009-2023  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,7 @@
 #endif
 
 #include <sstream>
+#include <sys/stat.h>
 
 const char Launcher::Job_CommandSALOME::TYPE_NAME[] = "command_salome";
 
@@ -42,9 +43,17 @@ Launcher::Job_CommandSALOME::~Job_CommandSALOME() {}
 std::string Launcher::Job_CommandSALOME::runCommandString()
 {
   std::ostringstream result;
-  result << _resource_definition.AppliPath
-         << "/salome shell ./"
-         << _job_file_name_complete;
+  struct stat statbuf;
+  if(stat(getenv("APPLI"), &statbuf) ==0 &&  S_ISREG(statbuf.st_mode))
+      // case of a salome launcher file
+      result << _resource_definition.AppliPath
+             << " shell ./"
+             << _job_file_name_complete;
+  else
+      // case of a salome appli dir
+      result << _resource_definition.AppliPath
+             << "/salome shell ./"
+             << _job_file_name_complete;
   return result.str();
 }
 #endif