Add a new CLI command, "core set chanvar", which allows you to set a channel

variable (or function) on an active channel from the CLI.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98558 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Russell Bryant 18 years ago
parent 3968dd1c3d
commit d0c89ab7ed

@ -76,6 +76,7 @@ CLI Changes
* Enhanced "agi debug" to print the channel name as a prefix to the debug * Enhanced "agi debug" to print the channel name as a prefix to the debug
output to make debugging on busy systems much easier. output to make debugging on busy systems much easier.
* New CLI commands "dialplan set extenpatternmatching true/false" * New CLI commands "dialplan set extenpatternmatching true/false"
* New CLI command: "core set chanvar" to set a channel variable from the CLI.
SIP changes SIP changes
----------- -----------

@ -4931,7 +4931,7 @@ static char *handle_set_global(struct ast_cli_entry *e, int cmd, struct ast_cli_
return NULL; return NULL;
} }
if (a->argc != 5) if (a->argc != e->args + 2)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
pbx_builtin_setvar_helper(NULL, a->argv[3], a->argv[4]); pbx_builtin_setvar_helper(NULL, a->argv[3], a->argv[4]);
@ -4940,6 +4940,44 @@ static char *handle_set_global(struct ast_cli_entry *e, int cmd, struct ast_cli_
return CLI_SUCCESS; return CLI_SUCCESS;
} }
static char *handle_set_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_channel *chan;
const char *chan_name, *var_name, *var_value;
switch (cmd) {
case CLI_INIT:
e->command = "core set chanvar";
e->usage =
"Usage: core set chanvar <channel> <varname> <value>\n"
" Set channel variable <varname> to <value>\n";
return NULL;
case CLI_GENERATE:
return ast_complete_channels(a->line, a->word, a->pos, a->n, 3);
}
if (a->argc != e->args + 3)
return CLI_SHOWUSAGE;
chan_name = a->argv[e->args];
var_name = a->argv[e->args + 1];
var_value = a->argv[e->args + 2];
if (!(chan = ast_get_channel_by_name_locked(chan_name))) {
ast_cli(a->fd, "Channel '%s' not found\n", chan_name);
return CLI_FAILURE;
}
pbx_builtin_setvar_helper(chan, var_name, var_value);
ast_channel_unlock(chan);
ast_cli(a->fd, "\n -- Channel variable '%s' set to '%s' for '%s'\n",
var_name, var_value, chan_name);
return CLI_SUCCESS;
}
static char *handle_set_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *handle_set_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
int oldval = 0; int oldval = 0;
@ -5009,6 +5047,7 @@ static struct ast_cli_entry pbx_cli[] = {
AST_CLI_DEFINE(handle_show_function, "Describe a specific dialplan function"), AST_CLI_DEFINE(handle_show_function, "Describe a specific dialplan function"),
AST_CLI_DEFINE(handle_show_application, "Describe a specific dialplan application"), AST_CLI_DEFINE(handle_show_application, "Describe a specific dialplan application"),
AST_CLI_DEFINE(handle_set_global, "Set global dialplan variable"), AST_CLI_DEFINE(handle_set_global, "Set global dialplan variable"),
AST_CLI_DEFINE(handle_set_chanvar, "Set a channel variable"),
AST_CLI_DEFINE(handle_show_dialplan, "Show dialplan"), AST_CLI_DEFINE(handle_show_dialplan, "Show dialplan"),
AST_CLI_DEFINE(handle_unset_extenpatternmatchnew, "Use the Old extension pattern matching algorithm."), AST_CLI_DEFINE(handle_unset_extenpatternmatchnew, "Use the Old extension pattern matching algorithm."),
AST_CLI_DEFINE(handle_set_extenpatternmatchnew, "Use the New extension pattern matching algorithm."), AST_CLI_DEFINE(handle_set_extenpatternmatchnew, "Use the New extension pattern matching algorithm."),

Loading…
Cancel
Save