1 |
torben |
35 |
#include "ShellExecPlugin.h" |
2 |
|
|
#include "GsmModem.h" |
3 |
|
|
|
4 |
|
|
#include "util.h" |
5 |
|
|
|
6 |
|
|
ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand) |
7 |
|
|
: Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ), |
8 |
|
|
_exeCommand(exeCommand) |
9 |
|
|
{ |
10 |
|
|
} |
11 |
|
|
|
12 |
|
|
void ShellExecPlugin::Execute(GsmModem& modem, SMS& sms) |
13 |
|
|
{ |
14 |
|
|
std::string parameters = GetSmsData(sms); |
15 |
torben |
38 |
parameters = Util::str_replace(parameters,";"); |
16 |
torben |
35 |
|
17 |
|
|
std::string command = _exeCommand + " " + parameters; |
18 |
|
|
int retval = ::system( command.c_str() ); |
19 |
|
|
|
20 |
|
|
std::string message; |
21 |
|
|
if (retval == -1) |
22 |
|
|
message = "Error"; |
23 |
|
|
else |
24 |
|
|
message = "OK"; |
25 |
|
|
|
26 |
|
|
modem.SendSms(sms.sender, message ); |
27 |
|
|
} |