I'm getting hostname and ip address from server(ubuntu 12.04) as explained here. It works correctly. After a while, i realize that server returns "(none)" as hostname when it is offline. Now i'm trying to eliminate this error by comparing hostname with "(none)". I tried all of these(*) but none of them works:
-- Getting hostname here
hostname=$(grep "host-name" /var/lib/dhcp/dhclient.${interface}.leases | tail -n1 | cut -d"\"" -f2 | cut -d"." -f1)
-- Trying to compare it with "(none)"
* if [ "$hostname" != "(none)" ] then ... else ... fi
* if [[ $hostname != "(none)" ]] then ... else ... fi
* nouser="(none)" if [ "$hostname" != "$nouser" ] then ... else ... fi
What am i doing wrong ? Thx for any help.
if [ "$hostname" != "(none)" ]; then ... else ... fiNote the;sign after]grep | tail | cutwithawk -F'"' '/host-name/ { print $2; exit }' /var/lib/....