Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for scripts/shell/sms/sity.sk/sms.sh between version 1.15 and 1.16

version 1.15, 2002/06/22 15:31:26 version 1.16, 2002/06/23 13:24:25
Line 18  CONFIG_FILE="$HOME/.sms.sh.conf";
Line 18  CONFIG_FILE="$HOME/.sms.sh.conf";
 ALIAS_FILE="$HOME/.sms.sh.alias";  ALIAS_FILE="$HOME/.sms.sh.alias";
   
 WWW="http://www.sity.sk/pls/sity"  WWW="http://www.sity.sk/pls/sity"
 TMP_FILE1=`tempfile -p sms. -s .html || mktemp /tmp/sms.XXXX.html || echo /tmp/sms.$$.html`  TMP_FILE1=`tempfile -p sms. -s .html \
 TMP_FILE2=`tempfile -p sms. -s .html || mktemp /tmp/sms.XXXX.html || echo /tmp/sms.$$.html`          || mktemp /tmp/sms.XXXX.html \
           || echo /tmp/sms.$$.html`
   TMP_FILE2=`tempfile -p sms. -s .html \
           || mktemp /tmp/sms.XXXX.html \
           || echo /tmp/sms.$$.html`
   
 if [ $# -lt 1 ]; then  if [ $# -lt 1 ]; then
         echo -e "Usage:\n       $0 <number-or-alias>\n";          echo -e "Usage:\n       $0 <number-or-alias>\n";
Line 30  fi
Line 34  fi
   
 number=`echo "$1" | grep '^[0-9]\+$'`;  number=`echo "$1" | grep '^[0-9]\+$'`;
   
   # check for alias {{{
 if [ -z "$number" ]; then  if [ -z "$number" ]; then
         echo "Parameter '$1' treated as an alias.";          echo "Parameter '$1' treated as an alias.";
         echo -n "Looking for alias file '$ALIAS_FILE': ";          echo -n "Looking for alias file '$ALIAS_FILE': ";
Line 41  if [ -z "$number" ]; then
Line 46  if [ -z "$number" ]; then
 #                       | sed 's/^'"$1"'[        ]*=\?[         ]*\([0-9]\+\)[   ]*$/\1/i' \  #                       | sed 's/^'"$1"'[        ]*=\?[         ]*\([0-9]\+\)[   ]*$/\1/i' \
 #                       | head -n 1`;  #                       | head -n 1`;
                 number=`awk "/^#/ { next; } \                  number=`awk "/^#/ { next; } \
                         // { gsub(/=/, \"\"); } \                  /^$1/ { if (NF > 2) { print \\$3; } \
                         /^$1/ { print \\$2; exit;}" "$ALIAS_FILE"`;                                  else { print \\$2; } exit; }" "$ALIAS_FILE"`;
                 if [ "$number" ]; then                  if [ "$number" ]; then
                         echo "found number $number.";                          echo "found number $number.";
                 else                  else
Line 52  if [ -z "$number" ]; then
Line 57  if [ -z "$number" ]; then
                 echo "not found.";                  echo "not found.";
         fi          fi
 fi  fi
   # }}}
   
 if [ -z "$number" ]; then  if [ -z "$number" ]; then
         echo "Undefined number. Aborting...";          echo "Undefined number. Aborting...";
         exit;          exit;
 fi  fi
   
 #if [ -f "$CONFIG_FILE" ]; then  # Config file parsing {{{
 #       NAME=`grep -v '^#' "$CONFIG_FILE" \  
 #               | grep -E '^username[   ]*=[    ]*' \  
 #               | sed 's/^username[     ]*=[    ]*\(.*\)[       ]*$/\1/' \  
 #               | head -n 1`;  
 #       PASS=`grep -v '^#' "$CONFIG_FILE" \  
 #               | grep -E '^password[   ]*=[    ]*' \  
 #               | sed 's/^password[     ]*=[    ]*\(.*\)[       ]*$/\1/' \  
 #               | head -n 1`;  
 #fi  
   
 # Lines begining with "^#" are comments and are ignored.  # Lines begining with "^#" are comments and are ignored.
 # equal sign '=' is not needed  # equal sign '=' is not needed
 # username, usernam userna, .. user supported  # username, usernam userna, .. user supported
 # password, ...                     supported  # password, ...                     supported
 if [ -f "$CONFIG_FILE" ]; then  if [ -f "$CONFIG_FILE" ]; then
         NAME=`awk '/^#/ { next; } // { gsub(/=/, ""); } /^user/ { print $2; exit;}' "$CONFIG_FILE"`;          NAME=`awk '/^#/ { next; } \
         PASS=`awk '/^#/ { next; } // { gsub(/=/, ""); } /^pass/ { print $2; exit;}' "$CONFIG_FILE"`;                  /^user/ { if (NF > 2) { print $3; } \
                           else { print $2; } exit; }' "$CONFIG_FILE"`;
           PASS=`awk '/^#/ { next; } \
                   /^pass/ { if (NF > 2) { print $3; } \
                           else { print $2; } exit; }' "$CONFIG_FILE"`;
 fi  fi
   # }}}
   
   # User's login from stdin {{{
 if [ -z "$NAME" ]; then  if [ -z "$NAME" ]; then
         echo -n 'Enter username: ';          echo -n 'Enter username: ';
         IF= read NAME;          IF= read NAME;
Line 97  if [ -z "$PASS" ]; then
Line 99  if [ -z "$PASS" ]; then
         stty echo;          stty echo;
         echo "<censored>"; # to write newline on output          echo "<censored>"; # to write newline on output
 fi  fi
   # }}}
   
   # Read message from stdin {{{
 #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'`;
 echo 'Enter your message (max 420 chars, lines will be joined with space):';  echo 'Enter your message (max 420 chars, lines will be joined with space, end with CTRL-D):';
 text=`cat` # text from stdin, multiple lines  text=`cat` # text from stdin, multiple lines
 text="`echo \"$text\" \  text="`echo \"$text\" \
         | awk 'BEGIN { ORS="+"} \          | awk 'BEGIN { ORS="+"} \
Line 110  text="`echo \"$text\" \
Line 114  text="`echo \"$text\" \
                 gsub(/ /, "+"); \                  gsub(/ /, "+"); \
                 gsub(/\&/, "%26"); \                  gsub(/\&/, "%26"); \
                 print; }'`"                  print; }'`"
   # }}}
   
   # Get cookies {{{
 # 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
 # Cookies format:  # Cookies format:
 #Set-Cookie: SITY=32E0DDB9AF9293E774AA1C0B5BCC0992;path=/  # ^Set-Cookie: SITY=32E0DDB9AF9293E774AA1C0B5BCC0992;path=/$
 echo 'Logging in...';  echo 'Logging in...';
 COOKIE=`GET -e -H "Cookie: SITY=SITY" \  COOKIE=`GET -e -H "Cookie: SITY=SITY" \
         $WWW/u_registrate2.login2?NAME="$NAME"\&PASSWD="$PASS"\&ASERVICE=0\&CMD=%21u_sms.home\&SERVICE=0 \          $WWW/u_registrate2.login2?NAME="$NAME"\&PASSWD="$PASS"\&ASERVICE=0\&CMD=%21u_sms.home\&SERVICE=0 \
         | awk 'BEGIN { FS="[=;]" } /^Set-Cookie:/ { print $2; }'`;          | awk 'BEGIN { FS="[=;]" } /^Set-Cookie:/ { print $2; }'`;
         #       | grep '^Set-Cookie' | sed 's/^Set-Cookie: SITY=\([0-9A-F]*\).*/\1/'`;          #       | grep '^Set-Cookie' | sed 's/^Set-Cookie: SITY=\([0-9A-F]*\).*/\1/'`;
   # }}}
   
   # Checking number of free SMSs {{{
 echo -n 'Checking number of free SMSs... ';  echo -n 'Checking number of free SMSs... ';
 #GET -H "Cookie: SITY=$COOKIE" \  #GET -H "Cookie: SITY=$COOKIE" \
 #       $WWW/u_profil.show_stat > $TMP_FILE1;  #       $WWW/u_profil.show_stat > $TMP_FILE1;
 #smss_sent=`grep '^<TD>[0-9]\+</TD>$' $TMP_FILE1 | head -n 1 | sed 's/<TD>\([0-9]\+\).*/\1/'`;  #smss_sent=`grep '^<TD>[0-9]\+</TD>$' $TMP_FILE1 \
   #       | head -n 1 | sed 's/<TD>\([0-9]\+\).*/\1/'`;
 smss_sent=`GET -H "Cookie: SITY=$COOKIE" \  smss_sent=`GET -H "Cookie: SITY=$COOKIE" \
         $WWW/u_profil.show_stat \          $WWW/u_profil.show_stat \
         | awk '/^<TD>[0-9]+<\/TD>$/ { gsub(/[><]/, " "); print $2;  exit; } '`;          | awk '/^<TD>[0-9]+<\/TD>$/ { gsub(/[><]/, " "); print $2;  exit; } '`;
   
 echo "100-$smss_sent" | bc;  echo "100-$smss_sent" | bc;
   # }}}
   
   # Retrieving submit forms... {{{
 echo 'Retrieving submit forms...';  echo 'Retrieving submit forms...';
 GET -H "Cookie: SITY=$COOKIE" \  GET -H "Cookie: SITY=$COOKIE" \
         $WWW/\!u_sms.home >$TMP_FILE1;          $WWW/\!u_sms.home >$TMP_FILE1;
   
 #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_FILE1 | sed 's/.*name="\([^"]*\)".*/\1/g'`;  textareaname=`grep 'textarea cols' $TMP_FILE1 \
 detailvalue=`grep 'DETAIL' $TMP_FILE1 | sed 's/.*value="\([^"]*\)".*/\1/g'`;          | sed 's/.*name="\([^"]*\)".*/\1/g'`;
   detailvalue=`grep 'DETAIL' $TMP_FILE1 \
           | 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;
   # }}}
   
   # Submitting SMS... {{{
 echo 'Submitting SMS...';  echo 'Submitting SMS...';
 GET -H "Cookie: SITY=$COOKIE" \  GET -H "Cookie: SITY=$COOKIE" \
         $WWW/\!u_sms.send_sms?MSG_TEXT="$text"\&SMSMsgLen=480\&SMScount=\&"$textareaname"="$number"\&BT.x=0\&BT.y=0\&DETAIL="$detailvalue" \          $WWW/\!u_sms.send_sms?MSG_TEXT="$text"\&SMSMsgLen=480\&SMScount=\&"$textareaname"="$number"\&BT.x=0\&BT.y=0\&DETAIL="$detailvalue" \
         > $TMP_FILE2;          > $TMP_FILE2;
   # }}}
   
 smss_left=`grep "Tento mesiac" $TMP_FILE2 | sed 's/.*va \([0-9]*\) spr.*/\1/'` ;  smss_left=`grep "Tento mesiac" $TMP_FILE2 \
           | 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.";
Line 157  else
Line 173  else
         echo "Something went wrong, see debug files ($TMP_FILE1, $TMP_FILE2).";          echo "Something went wrong, see debug files ($TMP_FILE1, $TMP_FILE2).";
 fi  fi
   
   
   # Modeline {{{
   # vim:set ts=4:
   # vim600:fdm=marker fdl=0 fdc=3 vb t_vb=:
   # }}}

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top