Browse code

First version of the script. Working, but not fancy

Raven authored on20/04/2015 20:07:32
Showing2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,8 @@
1
+Simon_Giotta,0794684385
2
+Seraina_Ceravolo,0764445555
3
+Samuel_Duetsch,0786346000
4
+Mile,0788855671
5
+Tse,0794338016
6
+Mum,0765189266
7
+Moni,0787389875
8
+Lio,0793294298
0 9
new file mode 100755
... ...
@@ -0,0 +1,53 @@
1
+#!/bin/bash
2
+#############
3
+user=raven
4
+password=b89e8bd7e3e456ad7c137f70818052f7 
5
+from=1
6
+action=send
7
+typ=2
8
+timestamp=0
9
+return=text
10
+httphead=1
11
+##############
12
+n=1;
13
+for entry in $(cat ~/src/sms/contacts);do
14
+echo $n $entry;
15
+n=$(($n+1))
16
+done;
17
+
18
+while true
19
+do
20
+  # (1) prompt user for recipent, and read command line argument
21
+   read -p "To: " toinput
22
+  # (2) handle the input we were given
23
+       case $toinput in
24
+            [\+0][0-9]* ) nr=$toinput; break;;
25
+            [1-9]* )    n=0;
26
+                        for entry in $(cat ~/src/sms/contacts);do
27
+                            n=$(($n+1))
28
+                            if (($n==$toinput)); then
29
+                                nr=$(echo $entry|cut -d ',' -f2)
30
+                            fi
31
+                        done
32
+                    break;;
33
+                * ) echo 'Please enter the nr. of an entry or a full phonenumber';;
34
+        esac
35
+done
36
+
37
+  # (3) prompt user for message content, and read command line argument
38
+read -p "Message:" messageinput
39
+while true
40
+do
41
+      # (1) prompt user, and read command line argument
42
+    read -p "Send message to $nr?[n] " answer
43
+      # (2) handle the input we were given
44
+     case $answer in
45
+        [nN]* ) action=info;break;;
46
+            * )  break;;
47
+      esac
48
+done
49
+echo -----------
50
+    curl http://www.sms-revolution.ch/API/httpsms.php -d user=$user \
51
+    -d password=$password --data-urlencode "text=$messageinput" \
52
+    -d to=$nr -d from=$from -d action=$action -d typ=$typ \
53
+    -d timestamp=$timestamp -d return=$return -d httphead=$httphead