From: Donald Lee Date: Sun, 4 Jul 2021 15:12:07 +0000 (+0800) Subject: lib: Update Script command example to call function X-Git-Tag: base_8.1~259^2~41 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a71096fb0a327baf9400ec6df964bfb696b18cfb;p=mirror%2Ffrr.git lib: Update Script command example to call function Signed-off-by: Donald Lee --- diff --git a/lib/command.c b/lib/command.c index 9dac60599c..b2b80daddd 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2428,18 +2428,20 @@ DEFUN(script, struct prefix p; (void)str2prefix("1.2.3.4/24", &p); - struct frrscript *fs = frrscript_load(argv[1]->arg, NULL); + struct frrscript *fs = frrscript_new(argv[1]->arg); if (fs == NULL) { vty_out(vty, "Script '/etc/frr/scripts/%s.lua' not found\n", argv[1]->arg); - } else { - int ret = frrscript_call(fs, ("p", &p)); - char buf[40]; - prefix2str(&p, buf, sizeof(buf)); - vty_out(vty, "p: %s\n", buf); - vty_out(vty, "Script result: %d\n", ret); } + if (frrscript_load(fs, argv[2]->arg, NULL)) + vty_out(vty, "Script function '/%s' not found\n", argv[2]->arg); + + int ret = frrscript_call(fs, argv[2]->arg, ("p", &p)); + char buf[40]; + prefix2str(&p, buf, sizeof(buf)); + vty_out(vty, "p: %s\n", buf); + vty_out(vty, "Script result: %d\n", ret); return CMD_SUCCESS; }