summaryrefslogtreecommitdiff
path: root/vtysh/vtysh.c
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-07-28 12:19:04 -0700
committerPaul Jakma <paul@quagga.net>2009-06-18 20:18:24 +0100
commit57fb974856b9ae143ca5642e279d181a45bbdd10 (patch)
tree5008d2b2fc2b061747d7afaf27c4f3f197f8ed93 /vtysh/vtysh.c
parent0fbd62a17c53f1e2695c0f96ffb437cd079abacb (diff)
[vtysh] Make vtysh more useable for scripting
Add environment variable (VTYSH_LOG) for logging. If a command fails, exit with non-zero exit code and don't continue multipart commands.
Diffstat (limited to 'vtysh/vtysh.c')
-rw-r--r--vtysh/vtysh.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 32b626c7..20f7df44 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -272,10 +272,10 @@ vtysh_pager_init (void)
}
/* Command execution over the vty interface. */
-static void
+static int
vtysh_execute_func (const char *line, int pager)
{
- int ret, cmd_stat;
+ int ret, cmd_stat = CMD_SUCCESS;
u_int i;
vector vline;
struct cmd_element *cmd;
@@ -288,7 +288,7 @@ vtysh_execute_func (const char *line, int pager)
vline = cmd_make_strvec (line);
if (vline == NULL)
- return;
+ return CMD_SUCCESS;
saved_ret = ret = cmd_execute_command (vline, vty, &cmd, 1);
saved_node = vty->node;
@@ -394,7 +394,7 @@ vtysh_execute_func (const char *line, int pager)
}
fp = NULL;
}
- return;
+ return CMD_SUCCESS;
}
ret = cmd_execute_command (vline, vty, &cmd, 1);
@@ -435,18 +435,19 @@ vtysh_execute_func (const char *line, int pager)
}
fp = NULL;
}
+ return cmd_stat;
}
-void
+int
vtysh_execute_no_pager (const char *line)
{
- vtysh_execute_func (line, 0);
+ return vtysh_execute_func (line, 0);
}
-void
+int
vtysh_execute (const char *line)
{
- vtysh_execute_func (line, 1);
+ return vtysh_execute_func (line, 1);
}
/* Configration make from file. */