In the below bash script, I am getting all IPs on a server and returning their GPS coordinates. The script works great without the if statement but it is returning "Please provide a valid IP address" after it returns around 10 or so IPs with their respective coordinates. Therefore, I assume the problem was the do traceroute command was being called even when "ip" was empty. Therefore, I put the
"if [[ $ip ]]"
in before the do so that it only executes when ip is not empty. However, now the script doesn't run... I get the error
"line 6: syntax error near unexpected token 'if'. line 6: 'if [[ $ip ]];'"
I've many different variations of the if statement to get it to work only to get the same error again. Any help please?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire