Skip to content

Instantly share code, notes, and snippets.

@henri
Last active October 23, 2024 20:21
Show Gist options
  • Save henri/b830bf51156302e51b975b3072f0d9c3 to your computer and use it in GitHub Desktop.
Save henri/b830bf51156302e51b975b3072f0d9c3 to your computer and use it in GitHub Desktop.
ping from stdin
#!/usr/bin/env bash
#
# This super basic script boiler plate
# will ping each host passed into the
# via stdin. Pipe your hosts into this
# script to check if they are up.
#
# Modify as needed for your purposes
#
# (C)2024 Henri Shustak - Released Under the GNU GPL 3.0 or later.
#
# version 1.0 - initial release - single ping only
#
while IFS= read -r line; do
# echo $line
ping -c 1 -W 0.5 "${line}" # | grep "packet" # | head -n 1
# echo $?
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment