]> Creatis software - bbtk.git/blob - packages/std/src/bbstdExecSystemCommand.cxx
*** empty log message ***
[bbtk.git] / packages / std / src / bbstdExecSystemCommand.cxx
1 #include "bbstdExecSystemCommand.h"
2 #include "bbstdPackage.h"
3 #include "bbtkInterpreter.h"
4
5 namespace bbstd
6 {
7
8   BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecSystemCommand);
9   BBTK_BLACK_BOX_IMPLEMENTATION(ExecSystemCommand,bbtk::AtomicBlackBox);
10
11   void ExecSystemCommand::bbUserConstructor() 
12   { 
13     bbSetInputIn("help");
14   }
15
16   void ExecSystemCommand::DoProcess()
17   {
18     bool ok=true;
19     int pos1=0,pos2;
20     pos2 = bbGetInputIn().find(";",pos1);
21     std::string ccommand;
22     while (ok)
23       {
24         if (pos2==-1) 
25           {
26             ok=false;
27             ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
28            } else {
29             ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
30           }
31           for (unsigned int i=0 ; i < ccommand.length() ; i++)
32           {
33             if (ccommand[i]==39)
34             {
35                   ccommand[i]=34;
36         }
37      }
38         std::cout << "*** Executing system command : '"<<ccommand<<"'"<<std::endl;
39         system ( ccommand.c_str() );
40         pos1=pos2+1;
41         pos2 = bbGetInputIn().find(";",pos2+1);
42       }
43
44     /* Grrr  not works in windows
45       int i;
46       char *str = (char*)bbGetInputIn().c_str();
47       char * pch;
48       pch = strtok (str,";");
49       while (pch != NULL)
50       {
51       std::string ccommand(pch);
52       for ( i=0 ; i < ccommand.length() ; i++)
53       {
54       if (ccommand[i]==39)
55       {
56       ccommand[i]=34;
57       }
58       }
59       
60       // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand );
61       system ( ccommand.c_str() );
62       pch = strtok (NULL, ";");
63       }
64       //      bbSetOutputOut( bbGetInputIn() );
65   */
66   }
67 } // EO namespace bbstd
68
69