]> Creatis software - bbtk.git/blob - packages/std/src/bbstdExecSystemCommand.cxx
=== MAJOR RELEASE ====
[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   
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         system ( ccommand.c_str() );
42         pos1=pos2+1;
43         pos2 = bbGetInputIn().find(";",pos2+1);
44       }
45     /*
46       int i;
47       char *str = (char*)bbGetInputIn().c_str();
48       char * pch;
49       pch = strtok (str,";");
50       while (pch != NULL)
51       {
52       std::string ccommand(pch);
53       for ( i=0 ; i < ccommand.length() ; i++)
54       {
55       if (ccommand[i]==39)
56       {
57       ccommand[i]=34;
58       }
59       }         
60       
61       // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand );
62       system ( ccommand.c_str() );
63       pch = strtok (NULL, ";");
64       }
65       //      bbSetOutputOut( bbGetInputIn() );   
66       */
67   }
68   
69   
70 } // EO namespace bbstd
71
72