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.16 and 1.17

version 1.16, 2002/06/23 13:24:25 version 1.17, 2002/06/24 09:21:22
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 \  TMP_FILE=`tempfile -p sms. -s .html \
         || mktemp /tmp/sms.XXXX.html \  
         || echo /tmp/sms.$$.html`  
 TMP_FILE2=`tempfile -p sms. -s .html \  
         || mktemp /tmp/sms.XXXX.html \          || mktemp /tmp/sms.XXXX.html \
         || echo /tmp/sms.$$.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";
         echo "Message is taken from standart input. Only one line is allowed.";          echo "Message is taken from standart input. Use special characters with care.";
         echo "Use special characters with care. Spaces are properly handled.";          echo "Spaces are properly handled.";
         exit 1;          exit 1;
 fi  fi
   
Line 37  number=`echo "$1" | grep '^[0-9]\+$'`;
Line 34  number=`echo "$1" | grep '^[0-9]\+$'`;
 # check for alias {{{  # 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'... ";
         if [ -f "$ALIAS_FILE" ]; then          if [ -f "$ALIAS_FILE" ]; then
                 echo "found.";                  echo "found.";
                 echo -n "Looking for alias '$1': ";                  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`;  
                 number=`awk "/^#/ { next; } \                  number=`awk "/^#/ { next; } \
                 /^$1/ { if (NF > 2) { print \\$3; } \                  /^$1/ { if (NF > 2) { print \\$3; } \
                                 else { 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
                         echo "not found.";                          echo "not found.";
                           exit 1;
                 fi                  fi
         else          else
                 echo "not found.";                  echo "not found.";
                   exit 1;
         fi          fi
 fi  fi
 # }}}  # }}}
   
 if [ -z "$number" ]; then  
         echo "Undefined number. Aborting...";  
         exit;  
 fi  
   
 # Config file parsing {{{  # Config file parsing {{{
 # 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
   # Hi rajo, fix your things before commiting in :-/ :
   #if [ -f "$CONFIG_FILE" ]; then
   #       NAME=`awk '/^#/ { next; } \
   #               /^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
   echo -n "Looking for alias file '$CONFIG_FILE'... ";
 if [ -f "$CONFIG_FILE" ]; then  if [ -f "$CONFIG_FILE" ]; then
         NAME=`awk '/^#/ { next; } \          echo "found.";
                 /^user/ { if (NF > 2) { print $3; } \          echo -n "Looking for username... ";
                         else { print $2; } exit; }' "$CONFIG_FILE"`;          NAME=`grep -v '^#' "$CONFIG_FILE" \
         PASS=`awk '/^#/ { next; } \          | grep -E '^user[a-z]*[   ]*=[    ]*' \
                 /^pass/ { if (NF > 2) { print $3; } \          | sed 's/^user[a-z]*[     ]*=[    ]*\(.*\)[       ]*$/\1/' \
                         else { print $2; } exit; }' "$CONFIG_FILE"`;          | head -n 1`;
           if [ -z "$NAME" ]; then
                   echo "not found.";
           else
                   echo "'$NAME'";
           fi
   
           echo -n "Looking for password... ";
           PASS=`grep -v '^#' "$CONFIG_FILE" \
           | grep -E '^pass[a-z]*[   ]*=[    ]*' \
           | sed 's/^pass[a-z]*[     ]*=[    ]*\(.*\)[       ]*$/\1/' \
           | head -n 1`;
           if [ -z "$PASS" ]; then
                   echo "not found.";
           else
                   echo "found.";
           fi
   else
           echo "not found.";
 fi  fi
 # }}}  # }}}
   
Line 83  fi
Line 101  fi
 if [ -z "$NAME" ]; then  if [ -z "$NAME" ]; then
         echo -n 'Enter username: ';          echo -n 'Enter username: ';
         IF= read NAME;          IF= read NAME;
 else  
         echo "Using username '$NAME' from configuration file '$CONFIG_FILE'.";  
 fi  fi
   
 if [ -z "$NAME" ]; then  if [ -z "$NAME" ]; then
Line 105  fi
Line 121  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'`;
 echo 'Enter your message (max 420 chars, lines will be joined with space, end with CTRL-D):';  echo 'Enter your message (max 420 chars, 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 116  text="`echo \"$text\" \
Line 132  text="`echo \"$text\" \
                 print; }'`"                  print; }'`"
 # }}}  # }}}
   
   #if [ -z "$text" ]; then
   if [ "$text" == "+" ]; then
           echo "Empty message is not allowed.";
           exit 1;
   else
           echo "'$text'";
   fi
   
 # Get cookies {{{  # 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:
Line 130  COOKIE=`GET -e -H "Cookie: SITY=SITY" \
Line 154  COOKIE=`GET -e -H "Cookie: SITY=SITY" \
 # Checking number of free SMSs {{{  # 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_FILE;
 #smss_sent=`grep '^<TD>[0-9]\+</TD>$' $TMP_FILE1 \  #smss_sent=`grep '^<TD>[0-9]\+</TD>$' $TMP_FILE \
 #       | head -n 1 | sed 's/<TD>\([0-9]\+\).*/\1/'`;  #       | 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 \
Line 143  echo "100-$smss_sent" | bc;
Line 167  echo "100-$smss_sent" | bc;
 # Retrieving submit forms... {{{  # 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_FILE;
   
 #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 \  textareaname=`grep 'textarea cols' $TMP_FILE \
         | sed 's/.*name="\([^"]*\)".*/\1/g'`;          | sed 's/.*name="\([^"]*\)".*/\1/g'`;
 detailvalue=`grep 'DETAIL' $TMP_FILE1 \  detailvalue=`grep 'DETAIL' $TMP_FILE \
         | sed 's/.*value="\([^"]*\)".*/\1/g'`;          | sed 's/.*value="\([^"]*\)".*/\1/g'`;
   
 echo 'Hold still, we need to wait 4 seconds.';  echo 'Hold still, we need to wait 4 seconds.';
Line 157  sleep 4;
Line 181  sleep 4;
   
 # Submitting SMS... {{{  # Submitting SMS... {{{
 echo 'Submitting SMS...';  echo 'Submitting SMS...';
 GET -H "Cookie: SITY=$COOKIE" \  smss_left=`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;          | grep "Tento mesiac" \
 # }}}  
   
 smss_left=`grep "Tento mesiac" $TMP_FILE2 \  
         | sed 's/.*va \([0-9]*\) spr.*/\1/'` ;          | 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.";
         rm -f $TMP_FILE1;          rm -f $TMP_FILE;
         rm -f $TMP_FILE2;  
 else  else
         echo "Something went wrong, see debug files ($TMP_FILE1, $TMP_FILE2).";          echo "Something went wrong, see debug file ($TMP_FILE).";
 fi  fi
   
   

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

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