How to get Perl to recognize 2 if statements for 2 conditions.
by crothman from LinuxQuestions.org on (#4R8S9)
Hello,
I have a perl script that I wrote to check if domainname is resolved when I run hostname -d. When I run my script, it always seems to check out fine when I have the hostname in /etc/hosts(it's supposed to come back with a blank line). Now when I remove the hostname from the hosts file and then run hostname -d it works and it resolves to prodtestbed.local which is what it is supposed to. The test is to remove the hostname in /etc/hosts and run the script and the output should be prodtestbed.local. Then rem it from hosts and it should come back blank. Any ideas on how to achieve this thru my script would be greatly appreciated.
if [[ $HOSTNAME =~ ^sfcurv || $HOSTNAME =~ ^lacurv || ;then
HOSTNAME_d=`hostname -d`
if [[ "${HOSTNAME_d}" != "prodtestbed.local" ]]; then
echo "Domainname is setup correctly.
else
if [[ "${HOSTNAME_d}" != " " ]]; then
echo "Please remove hostname $HOSTNAME from hosts file."
fi
fi
fi
Thank you
Charles


I have a perl script that I wrote to check if domainname is resolved when I run hostname -d. When I run my script, it always seems to check out fine when I have the hostname in /etc/hosts(it's supposed to come back with a blank line). Now when I remove the hostname from the hosts file and then run hostname -d it works and it resolves to prodtestbed.local which is what it is supposed to. The test is to remove the hostname in /etc/hosts and run the script and the output should be prodtestbed.local. Then rem it from hosts and it should come back blank. Any ideas on how to achieve this thru my script would be greatly appreciated.
if [[ $HOSTNAME =~ ^sfcurv || $HOSTNAME =~ ^lacurv || ;then
HOSTNAME_d=`hostname -d`
if [[ "${HOSTNAME_d}" != "prodtestbed.local" ]]; then
echo "Domainname is setup correctly.
else
if [[ "${HOSTNAME_d}" != " " ]]; then
echo "Please remove hostname $HOSTNAME from hosts file."
fi
fi
fi
Thank you
Charles