]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdExecSystemCommand.cxx
Feature #1676
[bbtk.git] / packages / std / src / bbstdExecSystemCommand.cxx
index f01fcb2941d3ef95b1db59c83def4fa0d2c159c4..598d70223403068ab5790a991612f4d7b59fe31c 100755 (executable)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbstdExecSystemCommand.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/07/12 16:31:00 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2012/10/11 10:49:45 $
+  Version:   $Revision: 1.11 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -56,13 +56,14 @@ namespace bbstd
     int pos1=0,pos2;
     pos2 = bbGetInputIn().find(";",pos1);
     std::string ccommand;
+    int result = 0;
     while (ok)
-      {
-       if (pos2==-1) 
+    {
+         if (pos2==-1) 
          {
            ok=false;
            ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
-          } else {
+         } else {
            ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
          }
          for (unsigned int i=0 ; i < ccommand.length() ; i++)
@@ -71,16 +72,30 @@ namespace bbstd
            {
                  ccommand[i]=34;
         }
-     }
-#if defined(_WIN32)
-       ccommand="start /b "+ccommand;
-#endif // defined(_WIN32)      
-       std::cout << "*** Executing system command : '"<<ccommand<<"'"<<std::endl;
-       system ( ccommand.c_str() );
-       pos1=pos2+1;
-       pos2 = bbGetInputIn().find(";",pos2+1);
       }
-
+      #if defined(_WIN32)
+           ccommand="start /b "+ccommand;
+      #endif // defined(_WIN32)        
+         std::cout << "*** Executing system command : '"<<ccommand<<"'"<<std::endl;
+         
+         result = system ( ccommand.c_str() );
+         
+         std::cout << "DFGO - ExecSystemCommand::DoProcess result=" << result << std::endl;
+         
+         //DFGO - if return code is different than 0 result is equal 1
+         
+         if(result)
+         {
+        result = 1;
+           ok = false;
+         }
+         pos1=pos2+1;
+         pos2 = bbGetInputIn().find(";",pos2+1);
+   }
+   
+   bbSetOutputReturn(result);
+   //std::cout << "DFGO - ExecSystemCommand::DoProcess result=" << result << std::endl;
+   
     /* Grrr  not works in windows
       int i;
       char *str = (char*)bbGetInputIn().c_str();