I wrote the following bash script to use with geektool. It loops through ip addresses 192.168.1.1 to 192.168.1.7, does a ping on each, and if the command succeeds, it echos the ip address. When run in terminal, it works perfectly.
The problem is that when I run this in geektool, it only displays the first active ip address it finds, then nothing. For some reason, when it encounters the first inactive ip address, geektool seems to stall. (It seems it's got to be something with geektool, otherwise the script wouldn't work correctly in terminal.)
If anyone can help me out, I'd be extremely grateful.
Peter V.
Code:
#!/bin/bash
for ip in $(seq 1 7); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] &&
echo "192.168.1.$ip is UP" || echo "$? inactive ip $ip" ; done
The correct output (when run in terminal) if ips 1,3,4, & 5 are up,
and the others are inactive:
192.168.1.1 is UP
1 inactive ip 2
192.168.1.3 is UP
192.168.1.4 is UP
192.168.1.5 is UP
1 inactive ip 6
1 inactive ip 7
The incorrect output (when run in geektool):
192.168.1.1
If anyone can help me out, I'd be extremely grateful.
Peter V.
Last edited: