Ajout d'un test pour savoir l'on doit uiliser curl ou wget

Ajout d'un test pour savoir si which est installé
This commit is contained in:
root 2020-04-27 22:43:12 +02:00
parent 6f8af2eaa1
commit a54759a7fc

View File

@ -71,7 +71,21 @@ if [ -z "${MESSAGE}" ] ; then
exit 1
fi
envoi=$(curl -i --insecure "https://smsapi.free-mobile.fr/sendmsg?user=${NOM}&pass=${PASS}&msg=${MESSAGE}" 2>&1)
if ! which which > /dev/null 2>&1 ; then
echo "which is not installed"
exit 1
elif which curl > /dev/null 2>&1 ; then
echo using curl
BIN="curl -i --insecure"
elif which wget > /dev/null 2<&1 ; then
echo using wget
BIN="wget --save-headers -qO -"
elif true ; then
echo "None of curl or wget installed" >&2
exit 1
fi
envoi=$(${BIN} "https://smsapi.free-mobile.fr/sendmsg?user=${NOM}&pass=${PASS}&msg=${MESSAGE}" 2>&1)
retour_HTTP=$(echo "${envoi}" | awk '/HTTP/ {print $2}')
case $retour_HTTP in
200)