2 - 1 = ?  
Entrer le résultat à partir de l'expression
Le maximum d'essais autorisés est : 10
 

Abonnés SFR, vous avez un nouveau message

Objet : Abonnés SFR, vous avez un nouveau message
par Anonyme sur 05-11-2005 13:13:08

Pour les linuxiens dont je ne doute pas qu'ils soient nombreux ici (!!!) voici un petit script qui envoie les prévisions des 3 prochains jours pour 1) Siouville 2) Wissant 3) Saint-Aubin, à  9h, 14h et 20h par MMS (le MMS doit être configuré sur votre portable) au format: Jour Heure Vitesse Orientation
a lancer de cette manière:
./<nom_du_fichier> <n°_de_tel_SFR> <n°_du_spot>

Attention, lorsqu'on ferme la console, ca arrête le script et donc, plus de messages

Ce truc utilise curl et awk qui doivent être installés.

Citation :

#!/bin/bash
#getwindguru expéditeur destinataire spot
#spot: 1 Siouville
#Spot: 2 Wissant
#Spot: 3 Saint AUbin

#Heures d'envoi de message
HR[1]=09
HR[2]=16
HR[3]=19
FILE='page'
URL='http://www.windguru.cz/int/index.php?go=1&lang=eng&wj=knots&tj=c&odh=0&doh=24&fhours=72&vs=1&sc='
FILE='page1'
BASE='http://sfr.annyway.net/mms?req=SFR.viewCreateMMSForm'
COOKIE='cookies.txt'

LAST=0
CUR=$(date|awk -F' ' '{print $4}'|awk -F':' '{print $1}')

A=0
B=1

case "$2" in
1)
echo 'Récupération des informations sur Siouville'
SPOTNAME='Siouville'
SPOT='186'
;;
2)
echo 'Récupération des informations sur Wisssant'
SPOTNAME='Wissant'
SPOT='110'
;;
3)
echo 'Récupération des informations sur Saint-Aubin'
SPOTNAME='Saint-Aubin'
SPOT='3627'
;;
*)
echo Erreur de numéro de spot
exit 1
;;
esac

until [ $A -eq $B ] ; do
GO=0
for I in `seq 1 3` ; do
if [ $LAST -lt ${HR[$I]} ] && [ $CUR -ge ${HR[$I]} ] ; then
GO=1
fi
done

CUR=$(date|awk -F' ' '{print $4}'|awk -F':' '{print $1}')
if [ $CUR -lt $LAST ] ; then
$LAST=0
fi
if [ $GO -eq 1 ] ; then
LAST=$CUR
#Récupération de la page WG
curl -s $URL$SPOT>$FILE
INIT=$(cat $FILE|egrep 'wg_INFO'|egrep 'GFS'|gawk -F"|" '{print $3}'|gawk -F"'" '{print $1}')
echo "envoi des données de $INIT heures à  $CUR heures"

for NUM in `seq 1 24` ; do
DAY[$NUM]=$(cat $FILE|egrep 'wg_DAY'|awk 'NR == 1 {print NR" : " $0 }'|awk -F"'" '{print $2 }'|awk -F";" '{print $'$NUM'}'|awk -F"," '{print $1}')
HOUR[$NUM]=$(cat $FILE|egrep 'wg_HR'|awk 'NR == 1 {print NR" : " $0 }'|awk -F"'" '{print $2 }'|awk -F";" '{print $'$NUM'}'|awk -F"," '{print $1}')
WIND[$NUM]=$(cat $FILE|egrep 'wg_WINDSPD'|awk 'NR == 1 {print NR" : " $0 }'|awk -F"'" '{print $2 }'|awk -F";" '{print $'$NUM'}'|awk -F"." '{print $1}')
ORIENT[$NUM]=$(cat $FILE|egrep 'wg_SMER'|awk 'NR == 1 {print NR" : " $0 }'|awk -F"'" '{print $2 }'|awk -F";" '{print $'$NUM'}')
done

TEXT='Donnees+de+'$INIT'h+pour+'$SPOTNAME':+'${DAY[1]}${HOUR[1]}'+'${WIND[1]}'+'${ORIENT[1]}
for NUM in `seq 2 24` ; do
TEXT=$TEXT'+-+'${DAY[$NUM]}'+'${HOUR[$NUM]}'+'${WIND[$NUM]}'+'${ORIENT[$NUM]}
done


#ENVOI DU MSS



rm -f $COOKIE

#Examen de la page initiale pour récupération des identifiants
curl -s -b $COOKIE -A 'Mozilla/3.04 (Win95; U)' -c $COOKIE $BASE>$FILE

#Récupération de la prochaine URL et des variables
NEWURL=$(cat $FILE|egrep action |egrep counter|egrep form|gawk -F'"' '{print $2}')
NEWURL=$(echo 'http://sfr.annyway.net'$NEWURL)
REQ=$(cat $FILE|egrep hidden|egrep req|gawk -F'"' '{print $6}')
PAGEID=$(cat $FILE|egrep hidden|egrep pageId|gawk -F'"' '{print $6}')
FOREGROUND=$(cat $FILE|egrep hidden|egrep foregroundColor|gawk -F'"' '{print $6}')
BACKGROUND=$(cat $FILE|egrep hidden|egrep backgroundColor|gawk -F'"' '{print $6}')
VIEWPAGENO=$(cat $FILE|egrep hidden|egrep viewPageNo|gawk -F'"' '{print $6}')
IMAGEID=$(cat $FILE|egrep hidden|egrep imageId|gawk -F'"' '{print $6}')
CATID=$(cat $FILE|egrep hidden|egrep catId|gawk -F'"' '{print $6}')
SESSIONID=$(cat $FILE|egrep hidden|egrep session_id|gawk -F'"' '{print $6}')
FROM=$1
FROM1=""
TO=$1
#Traitement des caractères spéciaux
FILENAME=""

#Envoi de la requette d'envoi de MMS
curl -s -L -b $COOKIE -c $COOKIE -A 'Mozilla/3.04 (Win95; U)' -d "req=$REQ&actionId=8&pageId=$PAGEID&foregroundColor=$FOREGROUND&backgroundColor=$BACKGROUND&viewPageNo=$VIEWPAGENO&to=$TO&imageId=$IMAGEID&catId=$CATID&from=$FROM&session_id=$SESSIONID&from1=$FROM1&filename=$FILENAME&text=$TEXT" $NEWURL>$FILE
rm -f $COOKIE
rm -f $FILE
else
sleep 60
fi

done
exit 0