| version 1.10, 2002/06/18 13:57:44 |
version 1.11, 2002/06/19 10:13:15 |
| Line 48 if [ -z "$PASS" ]; then |
|
| Line 48 if [ -z "$PASS" ]; then |
|
| echo "<censored>"; # to write newline on output |
echo "<censored>"; # to write newline on output |
| fi |
fi |
| |
|
| echo 'Enter your message (only one line, max 420 chars, it is binary safe):' |
echo 'Enter your message (only one line, max 420 chars, it is binary safe):'; |
| IF= read text |
IF= read text; |
| text=`echo "$text" | sed 's/%/%25/g; s/\+/%2B/g; s/ /+/g; s/&/%26/g'`; |
text=`echo "$text" | sed 's/%/%25/g; s/\+/%2B/g; s/ /+/g; s/&/%26/g'`; |
| |
|
| # download the file via special wget which stores session cookie to a file |
# download the file via special wget which stores session cookie to a file |
| echo 'Logging in...' |
echo 'Logging in...'; |
| COOKIE=`GET -e -H "Cookie: SITY=SITY" \ |
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 'Retrieving submit forms...' |
echo -n 'Checking number of free SMSs...'; |
| GET -H "Cookie: SITY=$COOKIE" \ |
GET -H "Cookie: SITY=$COOKIE" \ |
| http://www.sity.sk/pls/sity/\!u_sms.home >tmp.html |
http://www.sity.sk/pls/sity/u_profil.show_stat > tmp.html; |
| |
|
| |
smss_sent=`grep '^<TD>[0-9]\+</TD>$' tmp.html | head -n 1 | sed 's/<TD>\([0-9]\+\).*/\1/'`; |
| |
|
| |
smss_left=`echo "100-$smss_sent" | bc`; |
| |
|
| |
echo 'Retrieving submit forms...'; |
| |
GET -H "Cookie: SITY=$COOKIE" \ |
| |
http://www.sity.sk/pls/sity/\!u_sms.home >tmp.html; |
| |
|
| #we now extract textarea name, which will be used later |
#we now extract textarea name, which will be used later |
| textareaname=`grep 'textarea cols' tmp.html | sed 's/.*name="\([^"]*\)".*/\1/g'` |
textareaname=`grep 'textarea cols' tmp.html | sed 's/.*name="\([^"]*\)".*/\1/g'`; |
| detailvalue=`grep 'DETAIL' tmp.html | sed 's/.*value="\([^"]*\)".*/\1/g'` |
detailvalue=`grep 'DETAIL' tmp.html | sed 's/.*value="\([^"]*\)".*/\1/g'`; |
| |
|
| echo 'Hold still, we need to wait 4 seconds.' |
echo 'Hold still, we need to wait 4 seconds.'; |
| sleep 4 |
sleep 4; |
| |
|
| 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"="$1"\&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/'` ; |
| |
|
| if [ "$smss_left" ]; then |
if [ $smss_left ]; then |
| echo "Message sent. $smss_left SMSs left for this month." |
echo "Message sent. $smss_left SMSs left for this month."; |
| # delete unnecessary files, now leaving for debug.. |
rm -f tmp.html; |
| rm -f tmp.html |
rm -f tmp2.html; |
| rm -f tmp2.html |
|
| else |
else |
| echo 'Something went wrong, see debug files (tmp.html, tmp2.html).' |
echo 'Something went wrong, see debug files (tmp.html, tmp2.html).'; |
| fi |
fi |
| |
|