]> 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_USER_BLACK_BOX_IMPLEMENTATION(ExecSystemCommand,bbtk::AtomicBlackBox);
10   
11   void ExecSystemCommand::bbUserConstructor() 
12   { 
13     bbSetInputIn("help");
14   }
15   
16   
17   void ExecSystemCommand::DoProcess()
18   {
19     bool ok=true;
20     int pos1=0,pos2;
21     pos2 = bbGetInputIn().find(";",pos1);
22     std::string ccommand;
23     while (ok)
24       {                 
25         if (pos2==-1) 
26           {
27             ok=false;
28             ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
29           } 
30         else 
31           {
32             ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
33           }
34         for (int i=0 ; i < ccommand.length() ; i++)
35           {
36             if (ccommand[i]==39)
37               {
38                 ccommand[i]=34;
39               }
40           }                     
41         
42         system ( ccommand.c_str() );
43         pos1=pos2+1;
44         pos2 = bbGetInputIn().find(";",pos2+1);
45       }
46     /*
47       int i;
48       char *str = (char*)bbGetInputIn().c_str();
49       char * pch;
50       pch = strtok (str,";");
51       while (pch != NULL)
52       {
53       std::string ccommand(pch);
54       for ( i=0 ; i < ccommand.length() ; i++)
55       {
56       if (ccommand[i]==39)
57       {
58       ccommand[i]=34;
59       }
60       }         
61       
62       // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand );
63       system ( ccommand.c_str() );
64       pch = strtok (NULL, ";");
65       }
66       //      bbSetOutputOut( bbGetInputIn() );   
67       */
68   }
69   
70   
71 } // EO namespace bbstd
72
73