infinite nested while loop
Hi,
After much searching, I've decided to resort to the tried and true LQ Forums. Here's what I'm trying to accomplish: I need to ping several nodes one at a time with a single ping, over and over. When it reaches the bottom of the list, I want it to go back to the top and do it over again, infinitely. Here's what I tried so far: Code:
Thanks in advance, wolverene13 |
I busted my brains trying to figure out where your script calls itself. Finally, decided to run it with one modification. The variable $? returns the exit status of the last command, or according to BASH's textinfo pages:
Quote:
You can also do away with the if-then statement by using the && and || commands. Also redirect both stderr and stdout to /dev/null. Here my modified script: Code:
#!/bin/bash Code:
if ping -c 1 -w 1 $NODE &>/dev/null ; then Code:
echo "$(date +%H":"%M) $NODE alive" |
Quote:
|
From BASHs info pages:
Quote:
Code:
command1 && command2 || command3 It becomes: Code:
command1 && command2 Code:
command1 || command3 Code:
command1 && command2 || command3 Code:
if command1 ; then |
All times are GMT -5. The time now is 04:55 AM. |