Index: main/manager.c===================================================================--- main/manager.c (revision 70446)+++ main/manager.c (working copy)+static char mandescr_shell[] =+"Description: Run a shell command from manager.\n"+"Variables: (Names marked with * are required)\n"+" *Command: Command to execute\n"+" ActionID: Option Action id for message matching.\n"+" GetVar: Anything send within this field indicates you want the output of the shell command.\n";+++/*! \brief action:shell: Manager command "shell" - executes a command as if you were at the shell envirnment */+static int action_shell(struct mansession *s, struct message *m)+{+ /* Things to do: Thread this function, along with getinfo, so it doesnt slow down the GUI */+ FILE *ptr; + char plbuff[4096] = ""; /* Temporary Buffer */+ char buf[4096] = ""; /* Return Buffer */+ const char *cmd = astman_get_header(m, "Command");+ const char *id = astman_get_header(m, "ActionID"); /* Optional action ID, good for use in javascript...... */+ const char *getvar = astman_get_header(m, "getvar"); /* option to get return value */++ if (ast_strlen_zero(cmd)) { + astman_append(s, "No command specified!\n");+ return 0;+ }++ if (!ast_strlen_zero(id))+ astman_append(s, "ActionID: %s\r\n", id); /* we are going to send an action id, if they want it. */++ ptr = popen(cmd, "r");++ if (!ast_strlen_zero(getvar)) {+ while (fgets(plbuff, sizeof(plbuff), ptr)) { + strncat(buf, plbuff, strlen(buf) - 1); + }+ astman_append(s, buf);+ }++ pclose(ptr);++ return 0;+}+ /* helper function for originate */ struct fast_originate_helper { char tech[AST_MAX_EXTENSION];@@ -3282,6 +3323,7 @@ ast_manager_register2("Redirect", EVENT_FLAG_CALL, action_redirect, "Redirect (transfer) a call", mandescr_redirect ); ast_manager_register2("Originate", EVENT_FLAG_CALL, action_originate, "Originate Call", mandescr_originate); ast_manager_register2("Command", EVENT_FLAG_COMMAND, action_command, "Execute Asterisk CLI Command", mandescr_command );+ ast_manager_register2("Shell", EVENT_FLAG_COMMAND, action_shell, "Executes a Shell Command", mandescr_shell ); ast_manager_register2("ExtensionState", EVENT_FLAG_CALL, action_extensionstate, "Check Extension Status", mandescr_extensionstate ); ast_manager_register2("AbsoluteTimeout", EVENT_FLAG_CALL, action_timeout, "Set Absolute Timeout", mandescr_timeout ); ast_manager_register2("MailboxStatus", EVENT_FLAG_CALL, action_mailboxstatus, "Check Mailbox", mandescr_mailboxstatus );