From d95073f61f98ccd2273043f3c8e7d571584bdac1 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 2 Jan 2013 00:01:48 +0000 Subject: Replace io.popen with modelfunctions.run_executable --- bgp-model.lua | 6 ++---- ospf-model.lua | 6 ++---- zebra-model.lua | 5 ++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/bgp-model.lua b/bgp-model.lua index 467bc75..faa29ae 100644 --- a/bgp-model.lua +++ b/bgp-model.lua @@ -36,10 +36,8 @@ end local function telnetshowipbgp() local output = {} local configfile = parseconfigfile() or {} - local cmd = path .. "echo -e '" .. format.escapespecialcharacters(configfile.password) .. "\nshow ip bgp\nquit\n' | nc localhost bgpd 2>/dev/null" - local f = io.popen( cmd ) - local result = f:read("*a") or "" - f:close() + local cmd = (configfile.password or "") .. "\nshow ip bgp\nquit\n" + local result, errtxt = modelfunctions.run_executable({"nc", "localhost", "bgpd"}, false, cmd) if result == "" then result = "Failed to find routes" end diff --git a/ospf-model.lua b/ospf-model.lua index ca390ce..ae1c74d 100644 --- a/ospf-model.lua +++ b/ospf-model.lua @@ -36,10 +36,8 @@ end local function telnetshowip() local output = {} local configfile = parseconfigfile() or {} - local cmd = path .. "echo -e '" .. format.escapespecialcharacters(configfile.password) .. "\nshow ip ospf route\nquit\n' | nc localhost ospfd 2>/dev/null" - local f = io.popen( cmd ) - local result = f:read("*a") or "" - f:close() + local cmd = (configfile.password or "") .. "\nshow ip ospf route\nquit\n" + local result, errtxt = modelfunctions.run_executable({"nc", "localhost", "ospfd"}, false, cmd) if result == "" then result = "Failed to find routes" end diff --git a/zebra-model.lua b/zebra-model.lua index 2581d59..fc5b559 100644 --- a/zebra-model.lua +++ b/zebra-model.lua @@ -36,9 +36,8 @@ end local function telnetshowip() local output = {} local configfile = parseconfigfile() or {} - local cmd = path .. "echo -e '" .. format.escapespecialcharacters(configfile.password) .. "\nshow ip route\nquit\n' | nc localhost zebra 2>/dev/null" - local f = io.popen( cmd ) - local result = f:read("*a") or "" + local cmd = (configfile.password or "") .. "\nshow ip route\nquit\n" + local result, errtxt = modelfunctions.run_executable({"nc", "localhost", "zebra"}, false, cmd) local validoutput if result == "" then result = "Failed to find routes" -- cgit v1.2.3