Skip to content

Instantly share code, notes, and snippets.

@fd0
Created December 18, 2012 08:56
Show Gist options
  • Save fd0/4326302 to your computer and use it in GitHub Desktop.
Save fd0/4326302 to your computer and use it in GitHub Desktop.
#!/bin/bash
exec_target() {
TARGET=$1
shift
if ping -c 1 -W 1 $TARGET > /dev/null; then
"$@" "$TARGET"
else
echo "$TARGET unreachable"
fi
}
RANGE=$(seq 0 25)
PIDS=""
for SEQ in $RANGE; do
TARGET="10.12.${SEQ}.254"
exec_target "${TARGET}" "$@" &
PIDS="$PIDS $!"
done
# wait for all sub processes
for PID in $PIDS; do
wait $PID
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment