| version 1.12, 2002/06/19 13:12:55 |
version 1.13, 2002/06/20 10:50:37 |
|
|
| # sms.sh - sity.sk SMS sender |
# sms.sh - sity.sk SMS sender |
| # |
# |
| # Written by Martin Karas. |
# Written by Martin Karas. |
| |
# Alias support by Ondrej Jombik [20/6/2002] |
| # Based on script flash.sh by Ondrej Jombik |
# Based on script flash.sh by Ondrej Jombik |
| # Copyright (c) 2002 Platon SDG, http://www.platon.sk/ |
# Copyright (c) 2002 Platon SDG, http://www.platon.sk/ |
| # |
# |
|
|
| # $Id$ |
# $Id$ |
| |
|
| CONFIG_FILE="$HOME/.sms.sh.conf"; |
CONFIG_FILE="$HOME/.sms.sh.conf"; |
| |
ALIAS_FILE="$HOME/.sms.sh.alias"; |
| |
|
| if [ $# -lt 1 ]; then |
if [ $# -lt 1 ]; then |
| echo -e "Usage:\n $0 GSM_number\n"; |
echo -e "Usage:\n $0 <number-or-alias>\n"; |
| echo "Message is taken from standart input. Only one line is allowed."; |
echo "Message is taken from standart input. Only one line is allowed."; |
| echo "Use special characters with care. Spaces are properly handled."; |
echo "Use special characters with care. Spaces are properly handled."; |
| exit 1; |
exit 1; |
| fi |
fi |
| |
|
| |
number=`echo "$1" | grep '^[0-9]\+$'`; |
| |
|
| |
if [ -z "$number" ]; then |
| |
echo "Parameter '$1' treated as an alias."; |
| |
echo -n "Looking for alias file '$ALIAS_FILE': "; |
| |
if [ -f "$ALIAS_FILE" ]; then |
| |
echo "found."; |
| |
echo -n "Looking for alias '$1': "; |
| |
number=`grep -v '^#' "$ALIAS_FILE" \ |
| |
| grep -i -E '^'"$1"'[ ]*=?[ ]*' \ |
| |
| sed 's/^'"$1"'[ ]*=\?[ ]*\([0-9]\+\)[ ]*$/\1/i' \ |
| |
| head -n 1`; |
| |
if [ "$number" ]; then |
| |
echo "found number $number."; |
| |
else |
| |
echo "not found."; |
| |
fi |
| |
else |
| |
echo "not found."; |
| |
fi |
| |
fi |
| |
|
| |
if [ -z "$number" ]; then |
| |
echo "Undefined number. Aborting..."; |
| |
exit; |
| |
fi |
| |
|
| if [ -f "$CONFIG_FILE" ]; then |
if [ -f "$CONFIG_FILE" ]; then |
| NAME=`grep -E '^username[ ]*=[ ]*' $CONFIG_FILE \ |
NAME=`grep -v '^#' "$CONFIG_FILE" \ |
| | sed 's/^username[ ]*=[ ]*\(.*\)$/\1/' \ |
| grep -E '^username[ ]*=[ ]*' \ |
| |
| sed 's/^username[ ]*=[ ]*\(.*\)[ ]*$/\1/' \ |
| | head -n 1`; |
| head -n 1`; |
| PASS=`grep -E '^password[ ]*=[ ]*' $CONFIG_FILE \ |
PASS=`grep -v '^#' "$CONFIG_FILE" \ |
| | sed 's/^password[ ]*=[ ]*\(.*\)$/\1/' \ |
| grep -E '^password[ ]*=[ ]*' \ |
| |
| sed 's/^password[ ]*=[ ]*\(.*\)[ ]*$/\1/' \ |
| | head -n 1`; |
| head -n 1`; |
| fi |
fi |
| |
|
| Line 58 COOKIE=`GET -e -H "Cookie: SITY=SITY" \ |
|
| Line 89 COOKIE=`GET -e -H "Cookie: SITY=SITY" \ |
|
| http://www.sity.sk/pls/sity/u_registrate2.login2?NAME="$NAME"\&PASSWD="$PASS"\&ASERVICE=0\&CMD=%21u_sms.home\&SERVICE=0 \ |
http://www.sity.sk/pls/sity/u_registrate2.login2?NAME="$NAME"\&PASSWD="$PASS"\&ASERVICE=0\&CMD=%21u_sms.home\&SERVICE=0 \ |
| | grep '^Set-Cookie' | sed 's/^Set-Cookie: SITY=\([0-9A-F]*\).*/\1/'`; |
| grep '^Set-Cookie' | sed 's/^Set-Cookie: SITY=\([0-9A-F]*\).*/\1/'`; |
| |
|
| echo -n 'Checking number of free SMSs...'; |
echo -n 'Checking number of free SMSs... '; |
| GET -H "Cookie: SITY=$COOKIE" \ |
GET -H "Cookie: SITY=$COOKIE" \ |
| http://www.sity.sk/pls/sity/u_profil.show_stat > tmp.html; |
http://www.sity.sk/pls/sity/u_profil.show_stat > tmp.html; |
| |
|
|
|
| |
|
| echo 'Submitting SMS...'; |
echo 'Submitting SMS...'; |
| GET -H "Cookie: SITY=$COOKIE" \ |
GET -H "Cookie: SITY=$COOKIE" \ |
| http://www.sity.sk/pls/sity/\!u_sms.send_sms?MSG_TEXT="$text"\&SMSMsgLen=480\&SMScount=\&"$textareaname"="$1"\&BT.x=0\&BT.y=0\&DETAIL="$detailvalue" \ |
http://www.sity.sk/pls/sity/\!u_sms.send_sms?MSG_TEXT="$text"\&SMSMsgLen=480\&SMScount=\&"$textareaname"="$number"\&BT.x=0\&BT.y=0\&DETAIL="$detailvalue" \ |
| > tmp2.html; |
> tmp2.html; |
| |
|
| smss_left=`grep "Tento mesiac" tmp2.html | sed 's/.*va \([0-9]*\) spr.*/\1/'` ; |
smss_left=`grep "Tento mesiac" tmp2.html | sed 's/.*va \([0-9]*\) spr.*/\1/'` ; |