]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: Fix shell executed commands
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 31 Jul 2017 12:52:10 +0000 (08:52 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 9 Sep 2017 18:15:53 +0000 (14:15 -0400)
Pretty much all shell executed commands from vtysh were
not behaving correctly due to errors introduced in
switching to the new cli.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
vtysh/vtysh.c

index 00968531b79dd9dfc87248067027f75f87adc150..bfa9af62a50a9ee00d4043ac1fd8cb958d07c68c 100644 (file)
@@ -2267,7 +2267,7 @@ DEFUN (vtysh_show_daemons,
 
 /* Execute command in child process. */
 static void execute_command(const char *command, int argc,
-                           struct cmd_token *arg1, const char *arg2)
+                           const char *arg1, const char *arg2)
 {
        pid_t pid;
        int status;
@@ -2312,7 +2312,10 @@ DEFUN (vtysh_ping,
        "Send echo messages\n"
        "Ping destination address or hostname\n")
 {
-       execute_command("ping", 1, argv[0], NULL);
+       int idx = 1;
+
+       argv_find(argv, argc, "WORD", &idx);
+       execute_command("ping", 1, argv[idx]->arg, NULL);
        return CMD_SUCCESS;
 }
 
@@ -2327,7 +2330,10 @@ DEFUN (vtysh_traceroute,
        "Trace route to destination\n"
        "Trace route to destination address or hostname\n")
 {
-       execute_command("traceroute", 1, argv[0], NULL);
+       int idx = 1;
+
+       argv_find(argv, argc, "WORD", &idx);
+       execute_command("traceroute", 1, argv[idx]->arg, NULL);
        return CMD_SUCCESS;
 }
 
@@ -2343,7 +2349,7 @@ DEFUN (vtysh_ping6,
        "IPv6 echo\n"
        "Ping destination address or hostname\n")
 {
-       execute_command("ping6", 1, argv[0], NULL);
+       execute_command("ping6", 1, argv[2]->arg, NULL);
        return CMD_SUCCESS;
 }
 
@@ -2354,7 +2360,7 @@ DEFUN (vtysh_traceroute6,
        "IPv6 trace\n"
        "Trace route to destination address or hostname\n")
 {
-       execute_command("traceroute6", 1, argv[0], NULL);
+       execute_command("traceroute6", 1, argv[2]->arg, NULL);
        return CMD_SUCCESS;
 }
 
@@ -2365,7 +2371,7 @@ DEFUN (vtysh_telnet,
        "Open a telnet connection\n"
        "IP address or hostname of a remote system\n")
 {
-       execute_command("telnet", 1, argv[0], NULL);
+       execute_command("telnet", 1, argv[1]->arg, NULL);
        return CMD_SUCCESS;
 }
 
@@ -2376,7 +2382,7 @@ DEFUN (vtysh_telnet_port,
        "IP address or hostname of a remote system\n"
        "TCP Port number\n")
 {
-       execute_command("telnet", 2, argv[0], argv[1]);
+       execute_command("telnet", 2, argv[1]->arg, argv[2]->arg);
        return CMD_SUCCESS;
 }
 
@@ -2386,7 +2392,7 @@ DEFUN (vtysh_ssh,
        "Open an ssh connection\n"
        "[user@]host\n")
 {
-       execute_command("ssh", 1, argv[0], NULL);
+       execute_command("ssh", 1, argv[1]->arg, NULL);
        return CMD_SUCCESS;
 }