LOCAL_IP=ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'
sets the variable LOCAL_IP
to ifconfig
to run an empty command, and sends the empty output of that empty command to the pipe built of | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'
. So LOCAL_IP
is never set afterwards.
What you probably want to run is
LOCAL_IP=$(ifconfig | grep 'inet ' | grep -Fv 127.0.0.1 | awk '{print $2}')
which can be simplified to
LOCAL_IP=$(ifconfig | awk '/inet /&&!/127.0.0.1/{print $2}')
Unfortunately this will return two rows on Macs which are connected over both Ethernet and WLAN. So it's probably safer to use
LOCAL_IP=$(ifconfig | awk '/inet /&&!/127.0.0.1/{print $2;exit}')
which will pick the first network interface/IP address found.