I tried to print the value returned from testfunction. But it is not displaying anything . I used ./filename.sh to execute the script. Please help
#!/bin/ksh
testfunction()
{
k=5
return $k
}
val=$(testfunction)
echo $val
This ksh functions works:
IPADDRESS() # get the IP address of this host
{
# purpose: to get the IP address of this host
# and return it as a character string
#
typeset -l IPADDR
IPADDR=$(ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{print $2}')
print $IPADDR
}
IP_Address=$(IPADDRESS)
echo $IP_Address
exit