-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurl.sh
50 lines (43 loc) · 1.57 KB
/
curl.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
################################
## Auteur: HGK
## Date: 27/08/2016
## Version: 1.0
## Description: Script de test
################################
# Constants definition
# -----------------------------------------------------------------------------
HOST = "www.verychic.com"
LOGIN = "[email protected]"
MDP = "travelsoft"
COOKIE = "cookieverychic"
EMAIL = "[email protected]"
#Function to connect on website
# -----------------------------------------------------------------------------
Connect() {
# curl -c cookieverychic -u [email protected]:travelsoft www.verychic.com
curl -c $4 -u $1:$2 $3
}
#Function to find product
# -----------------------------------------------------------------------------
FindProduct(){
#curl -b cookieverychic -u [email protected]:travelsoft www.verychic.com -d "destination=spain" -d "Price >= 100"
curl -c $4 -u $1:$2 $3 -d "destination=spain" -d "Price >= 100" --ignore-content-length > spain100.txt
Nombre = $(wc -l spain.txt)
echo "Le Nombre de produit est $Nombre"
}
#Function to send mail
# -----------------------------------------------------------------------------
SendMail() {
echo $3 | mail -s $2 $1
}
############ Main Program ##############
Connect $HOST $LOGIN $MDP $COOKIE
if [$? -ne 0];then
SendMail $EMAIL "Problème de connexion" "Impossible de se connecter au site web"
exit 1
else
FindProduct $LOGIN $MDP $HOST $COOKIE
SendMail $EMAIL "Nombre de produit espagne" "Le nombre de produit à destination de l'espagne dont le prix est supérieur à 100: $Nombre"
exit 0
fi