From a54759a7fc60c300d277b5f2b188c219ab9d7ede Mon Sep 17 00:00:00 2001 From: root Date: Mon, 27 Apr 2020 22:43:12 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20test=20pour=20savoir=20l'on=20do?= =?UTF-8?q?it=20uiliser=20curl=20ou=20wget=20Ajout=20d'un=20test=20pour=20?= =?UTF-8?q?savoir=20si=20which=20est=20install=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sms/freesms | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sms/freesms b/sms/freesms index a4e7589..fe511f6 100755 --- a/sms/freesms +++ b/sms/freesms @@ -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)