-
Notifications
You must be signed in to change notification settings - Fork 0
/
iserv_email.sh
54 lines (41 loc) · 1.09 KB
/
iserv_email.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
51
52
53
54
#!/bin/bash
# This code is under the MIT License (MIT)
# See LICENSE -file for whole license
iservhost=""
lact=""
lpwd=""
cookiefile="/tmp/iservcookie.txt"
curl --silent -d "login_act=$lact&login_pwd=$lpwd" -c "$cookiefile" "$iservhost" > /dev/null
alles=$(curl -b "$cookiefile" "${iservhost}msg/list.php?INBOX")
alles=${alles#*"</head>"}
alles=${alles%"<script"*}
suchenach=$(grep -c "'bold'" <<< "$alles")
a=0
output=""
for a in $(seq 1 $suchenach)
do
alles=${alles#*"'bold' id='id"}
#get email hash (idhash)
idhash=${alles:0:8}
# get email-ID
alles=${alles#*"INBOX/"}
id=${alles:0:8}
id=${id%"'"*}
# get Email subject
alles=${alles#*"class='r2'>"}
subject=${alles%%"</td></tr>"*}
# remove html tags
subject=$(echo "$subject" | sed 's/&[^>]*;//g' | sed 's/<[^>]*>//g')
# store in arrays
output="$output\n$subject\n${iservhost}msg/msg.php?INBOX/$id\n"
done
if [[ "$a" == "1" ]]
then s=":"
elif [[ "$a" == "0" ]]
then s="s."
else
s="s:"
fi
#echo -e "You got $a new eMail$s\n$output" > output.txt
echo -e "You got $a new eMail$s\n$output"
rm $cookiefile > /dev/null