[Freeswitch-svn] [commit] r9459 - in freeswitch/trunk/src/mod/applications: mod_commands mod_dptools

Freeswitch SVN brian at freeswitch.org
Fri Sep 5 00:09:51 EDT 2008


Author: brian
Date: Fri Sep  5 00:09:50 2008
New Revision: 9459

Modified:
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c

Log:
MODAPP-138 with tweaks

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Fri Sep  5 00:09:50 2008
@@ -2505,6 +2505,23 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+#define SYSTEM_SYNTAX "<command>"
+SWITCH_STANDARD_API(system_function)
+{
+    if (switch_strlen_zero(cmd)) {
+        stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX);
+        return SWITCH_STATUS_SUCCESS;
+    } 
+
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n", cmd);
+    if (system(cmd) < 0) {
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", cmd);
+    }
+    stream->write_function(stream, "+OK\n");
+    return SWITCH_STATUS_SUCCESS;
+}
+
+
 SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
 {
 	switch_api_interface_t *commands_api_interface;
@@ -2589,6 +2606,7 @@
 	SWITCH_ADD_API(commands_api_interface, "module_exists", "check if module exists", module_exists_function, "<module>");
 	SWITCH_ADD_API(commands_api_interface, "uuid_send_dtmf", "send dtmf digits", uuid_send_dtmf_function, UUID_SEND_DTMF_SYNTAX);
 	SWITCH_ADD_API(commands_api_interface, "eval", "eval (noop)", eval_function, "<expression>");
+	SWITCH_ADD_API(commands_api_interface, "system", "Execute a system command", system_function, SYSTEM_SYNTAX);
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_NOUNLOAD;

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Fri Sep  5 00:09:50 2008
@@ -1185,7 +1185,7 @@
 SWITCH_STANDARD_APP(system_session_function)
 {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n", data);
-	if (!system(data)) {
+	if (system(data) < 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", data);
 	}
 }



More information about the Freeswitch-svn mailing list