First I want to apologize for being an absolute noob at programming, writing scripts, etc. I have a question about some code I used to run on my old FreeNAS 11.1 machine. I also created a thread back when I initiated the script. Back then I got the help and my script worked. Now I updated to FreeNAS 11.2 and get some messages and I want to know why they appear and how to fix this.
But first the Background. My script checks if any Client is online (by pinging the IP-address):
#!/bin/bash
HOST1=10.10.0.100 #Client 1
HOST2=10.10.0.101 #Client 2
HOST3=10.10.0.102 #Client 3
HOST4=10.10.0.103 #Client 4
HOST5=10.10.0.104 #Client 5
_exit () {
case $1 in
1) echo „No Shutdown – At least one PC is online“ ;;
2) echo „No PC is online – Shutdown“ ;; shutdown -p now }
#Check if IPs are online
if [ `ping -c 1 -i 1 $HOST1 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST2 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST3 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST4 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST5 | grep -wc 100.0%` -eq 0 ] ; then _exit 1;
#All Clients are offline, shutdown else
_exit 2 fi
The script itself works fine. If one client is online the script stops and if all clients are offline the Server shutsdown. But i get the following message when i run it manually via the Shell:
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
shutdown_check.sh: -wc not found
[: -eq: unexpected operator
When I ran it on my old Server (11.1) i did not get this message so it is interesting for my, why it now occurs.