I am sorry for my dump question. I am really new to shell scripting and still learning. I tried to add the if then else to my script but since I added it, I am always getting an error. Can someone have a look at it and tell my what I have done wrong?
Target: If the output of “whois”, “whois2”, “whois3” is empty it should be replaced with text, otherwise it should take the value. All has to be written into an output.
> #!/bin/bash > # Bulk Domain Lookup > # > # File name/path of domain list: > domain_list='domains.txt' # One FQDN per line in file. > # > # IP address of the nameserver used for lookups: > ns_ip='126.96.36.199' # Is using Google NS > # > # Seconds to wait between lookups: > loop_wait='1' > > echo "Domain;Registrar;Country;Owner"; #Headers > for domain in `cat $domain_list` > do > ns=`dig ns $domain |sed -ne '16p'`; #nameserver lookup & use only line 16 from output > ip=`dig @$ns_ip +short $domain |tail -n1`; # IP address lookup > mx=`dig mx $domain +short`; #mailserver lookup & use only line 11 from output > whois=`whois $domain |grep -i "Registrar:" | tail -n 1`; > whois2=`whois $domain |grep -i "Registrant Country:" | tail -n 1`; > whois3=`whois $domain |grep -i "Registrant Organization:" | tail -n 1`; > if [ -z "$whois" -eq ""]; > then echo "No Data"; > elif [echo $whois]; > if [ -z "$whois2" -eq ""]; > then echo "No Data"; > elif [echo $whois2]; > if [ -z "$whois3" -eq ""]; > then echo "No Data"; > elif [echo $whois3]; > echo "$domain;$whois;$whois2;whois3;$ns;$ip;mx;"; #Output order > > sleep $loop_wait # Pause before the next lookup to avoid flooding NS > done; > ------end script------
Upfront, thank you for your help!!