Bonsoir,
Je voudrai faire une remontée d'alarme via des sms.
J'ai trouvé le script suivant pour envoyer des sms en bash mais je n'arrive pas à le faire fonctionner.
Voici le script:
voici comment je l'exécute:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 #!/bin/sh # # Sample script to send an SMS email notifcation to aql's HTTP gateways # Username and password associated with aql account username= password= number= message="Test message" if [ $# -eq 0 ]; then echo "Usage: $0 -n [number] -m [message] -u [username] -p [password]"; echo ""; echo "[number] = SMS number to send message to"; echo "[message] = Text of message you want to send"; echo "[username] = Username assocated with aql account"; echo "[password] = Password assocated with aql account"; echo " Both the username and password options are optional and"; echo " override the account credentials defined in this script."; echo ""; exit 1; fi # Get command line arguments while [ "$1" != "" ] ; do case $1 in -n) # Get the SMS number that we should send message to number=$2; shift 2; ;; -m) # Get the message we should send message=$2; shift 2; ;; -u) # Get the username username=$2; shift 2; ;; -p) # Get the password password=$2; shift 2; ;; *) echo "Unknown option: $1" exit 1; ;; esac done message_sent_ok=0; for server in gw1 gw11 gw2 gw22; do RESPONSE=`curl -s -d username=$username -d password=$password -d to_num=$number -d message="$message" http://$server.aql.com/sms/postmsg.php` if [ "$?" -eq "0" ]; then case $RESPONSE in AQSMS-OK) # Message was queued ok mesage_sent_ok=1; echo "Message posted OK to HTTP gateway $server" exit 0; ;; AQSMS*) # Some kind of fatal error occurred echo "Fatal error received from HTTP gateway $server: $RESPONSE" exit 1; ;; *) # No response or invalid response ;; esac fi done
mais ça ne marche pas j'ai ces erreurs là:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 bash alarm -n numéro -m "attaque réseau!"
comment je fais?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 alarm: line 49: curl: command not found alarm: line 50: http://gw1.aql.com/sms/postmsg.php: No such file or directory alarm: line 49: curl: command not found alarm: line 50: http://gw11.aql.com/sms/postmsg.php: No such file or directory alarm: line 49: curl: command not found alarm: line 50: http://gw2.aql.com/sms/postmsg.php: No such file or directory alarm: line 49: curl: command not found alarm: line 50: http://gw22.aql.com/sms/postmsg.php: No such file or directory
Merci
Partager