I have following function which checks connection for internet (I know there are better ways to check for internet connection but that's not the topic):
function checkInternet() {
local HOST="http://google.com"
local WGET="/usr/bin/wget"
$WGET -q --tries=10 --timeout=10 --spider $HOST
if [[ $? -eq 0 ]]
then
echo "online"
else
echo "offline"
fi
}
Now I want to request the return value of the function directly in an if-statement:
I tried several scripts similar to e.g. this one (what I found here):
if( $(checkInternet) -eq "online" )
then
echo "Function returned online"
else
echo "Function returned offline"
fi
I don't want to initialisize further variables before the if-statement what I meant with "directly".