The topology script which was copied by customer from above link was missing "fi" on last line and hence was giving above exception.
RESOLUTION: Populated corrected script rack-topology.sh on namenode and datanodes and tried starting the datanodes after which datanode service was able to startup.