I'm trying to print IP address of a particular interface using luci.sys.exec() function. My requirement is to add a variable which consists of the interface name for eg: eth0 or eth1.
code executed is :
local interfacename= "eth0"
currentInterfaceIpAdd = luci.util.trim(luci.sys.exec("ifconfig " ..interfacename.." | grep 'inet' | awk '{gsub("addr:","",$2); print $2 }'"))
Error is also observed because of the double quotes in gsub("addr:","",$2). But single quotes gives nill value. The same command with static interface name works fine in command line.