/[projects]/smsdaemon/plugins/ShellExecPlugin.cpp
ViewVC logotype

Diff of /smsdaemon/plugins/ShellExecPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 106 by torben, Mon Jun 16 10:21:02 2008 UTC revision 107 by torben, Thu Jun 19 14:47:52 2008 UTC
# Line 4  Line 4 
4    
5  #include "util.h"  #include "util.h"
6    
7  ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand, bool allowParameters)  ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand, bool allowParameters, bool returnOutput)
8    : Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ),    : Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ),
9    _exeCommand(exeCommand),    _exeCommand(exeCommand),
10    _allowParameters(allowParameters)    _allowParameters(allowParameters),
11      _returnOutput(returnOutput)
12  {  {
13  }  }
14    
# Line 28  void ShellExecPlugin::Execute(IGsmModem& Line 29  void ShellExecPlugin::Execute(IGsmModem&
29                  command += " ";                  command += " ";
30                  command += parameters;                  command += parameters;
31          }          }
32          int retval = Util::my_system( command.c_str()  );          std::string output;
33            std::string* out_p = 0;
34    
35            if (_returnOutput)
36                    out_p = &output;
37    
38            int retval = Util::my_system( command.c_str(), out_p );
39    
40          std::string message;          std::string message;
41          if (retval == -1)          if (retval == -1)
42                  message = "Error";                  message = "Error";
43          else          else
44                  message = "OK";          {
45                    if (_returnOutput)
46                            message = output;
47                    else
48                            message = "OK";
49            }
50                    
51          modem.SendSms(sms.sender, message, false );          modem.SendSms(sms.sender, message, false );
52  }  }

Legend:
Removed from v.106  
changed lines
  Added in v.107

  ViewVC Help
Powered by ViewVC 1.1.20