Skip to content

Instantly share code, notes, and snippets.

@y0t4
Created May 24, 2014 08:01
Show Gist options
  • Save y0t4/8f0643ce1996a9b69eba to your computer and use it in GitHub Desktop.
Save y0t4/8f0643ce1996a9b69eba to your computer and use it in GitHub Desktop.
適当にモジュール作成してみる
#!/bin/bash
eval $(perl -lne 'while(/\s?([^=\s]+)\s?=\s?(\"(?:\\\"|[^\"])+\"|\x27(?:\x27\\\x27\x27|[^\x27])+\x27|\S+)\s?/g){print "$1=$2"}' $1)
if [ -z "${ip}" ]; then
printf "rc=0 changed=False ip='ip not found'"
exit 0
fi
ping -w 3 ${ip} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "changed=True"
exit 0
else
echo "changed=False msg=\'ping failed\'"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment