I am using AIX 6.1. Below code is working fine for me.
if [ "$HOSTNAME" = "host1" ]; then
echo "This is host1"
elif [ "$HOSTNAME" = "host2" ]; then
echo "This is host2"
else
echo "This is another host"
fi
But when I use Shebang in my code, always the last else part is getting executed even if the first/second if conditions are true.
#!/bin/sh
if [ "$HOSTNAME" = "host1" ]; then
echo "This is host1"
elif [ "$HOSTNAME" = "host2" ]; then
echo "This is host2"
else
echo "This is another host"
fi
How can I get the same output as in first code snippet but with using shebang.
P.S. : I can't write the script without using shebang due to some constraints.