jeudi 14 mai 2015

IF statement inside a loop in linux terminal not working

Currently I am trying to execute a bash file in a crontab. However, the command by itself is not working, this is the command.

for ip in $(seq 3 80); do for ip2 in $(seq 9 254); do count=$(ping -c 1 192.168.$ip.$ip2 | grep icmp* | wc -l) if [ $count -eq 0 ]; then echo "Host unreachable" else php /var/www/phpfile.php 192.168.$ip.$ip2 > 192.168.$ip.$ip2.txt; done; done

The error that the console is showing when I execute this command is this:

if: Command not found

I already checked the spaces between the brackets, I also tried to remove them, but none of those solutions have worked. Can you please tell me what is wrong with my command? What am I missing?

Thank you so much in advance.

Aucun commentaire:

Enregistrer un commentaire