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.33 and 1.40

version 1.33, 2002/07/31 21:09:02 version 1.40, 2002/07/31 23:21:44
Line 24  CONFIG_FILE="$HOME/.sms.sh.conf";
Line 24  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_FILE=`tempfile -p sms. -s .html \  
         || mktemp /tmp/sms.XXXXXX \  
         || echo /tmp/sms.$$.html`  
   
 # Function usage() {{{  # Function usage() {{{
 usage()  usage()
 {  {
Line 201  do
Line 197  do
                         --tmp=* | --tm=* | --t=* | \                          --tmp=* | --tm=* | --t=* | \
                         -tmp-file=* | -tmp-fil=* | -tmp-fi=* | -tmp-f=* | \                          -tmp-file=* | -tmp-fil=* | -tmp-fi=* | -tmp-f=* | \
                         -tmp=* | -tm=* | -t=*)                          -tmp=* | -tm=* | -t=*)
                         # first remove already created $TMP_FILE and create new empty                          TMP_FILE="$optarg" ;;
                         rm -f $TMP_FILE;  
                         TMP_FILE="$optarg"; touch $TMP_FILE ;;  
   
                 --username | --usernam | --userna | --usern | --user | \                  --username | --usernam | --userna | --usern | --user | \
                         --use | --us | --u | \                          --use | --us | --u | \
Line 238  do
Line 232  do
 done  done
 # Cmdline parsing }}}  # Cmdline parsing }}}
   
 #number=`echo "$1" | grep '^[0-9]\+$'`;  # create tmpfile only if '--debug' is on
   if [ ! -z "$DEBUG" ]; then
           # if '--tmpfile' not specified on cmdline, create tmpfile with tempfile
           test -z "$TMP_FILE" \
           && TMP_FILE=`tempfile -p sms. -s .html \
                   || mktemp /tmp/sms.XXXXXX \
                   || echo /tmp/sms.$$.html`
   fi
   
 number=`echo "$prev_number" | grep '^[0-9]\+$'`;  number=`echo "$prev_number" | grep '^[0-9]\+$'`;
   
 # check for alias {{{  # check for alias {{{
Line 341  fi
Line 343  fi
 # }}}  # }}}
   
 # Read message from stdin {{{  # Read message from stdin {{{
 #echo 'Enter your message (only one line, max 420 chars, it is binary safe):';  
 #IF= read text;  
 #text=`echo "$text" | sed 's/%/%25/g; s/\+/%2B/g; s/ /+/g; s/&/%26/g'`;  
 echo 'Enter your message (max 420 chars, 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\" \
Line 355  text="`echo \"$text\" \
Line 354  text="`echo \"$text\" \
                 print; }'`"                  print; }'`"
 # }}}  # }}}
   
 #if [ -z "$text" ]; then  
 if [ "x$text" == "x+" ]; then  if [ "x$text" == "x+" ]; then
         echo "Empty message is not allowed.";          echo "Empty message is not allowed.";
         exit 1;          exit 1;
 #else  
 #       echo "'$text'";  
 fi  fi
   
 # Get cookies {{{  # Get cookies {{{
Line 371  echo 'Logging in...';
Line 367  echo 'Logging in...';
 COOKIE=`$GET -P -e -H "Cookie: SITY=SITY" \  COOKIE=`$GET -P -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/'`;  
 # }}}  # }}}
   
 # 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 -P -H "Cookie: SITY=$COOKIE" \  
 #       $WWW/u_profil.show_stat > $TMP_FILE;  
 #smss_sent=`grep '^<TD>[0-9]\+</TD>$' $TMP_FILE \  
 #       | head -n 1 | sed 's/<TD>\([0-9]\+\).*/\1/'`;  
 smss_sent=`$GET -P -H "Cookie: SITY=$COOKIE" \  smss_sent=`$GET -P -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; } '`;
Line 389  echo "100-$smss_sent" | bc;
Line 380  echo "100-$smss_sent" | bc;
   
 # Retrieving submit forms... {{{  # Retrieving submit forms... {{{
 echo 'Retrieving submit forms...';  echo 'Retrieving submit forms...';
 $GET -P -H "Cookie: SITY=$COOKIE" \  
         $WWW/\!u_sms.home >$TMP_FILE;  
   
 #we now extract textarea name, which will be used later  # if --debug option is specified, save output from $GET to $TMP_FILE,
 textareaname=`grep 'textarea cols' $TMP_FILE \  # else do nothing
         | sed 's/.*name="\([^"]*\)".*/\1/g'`;  if [ ! -z "$NAME" ]; then
 detailvalue=`grep 'DETAIL' $TMP_FILE \          SAVE_DEBUG_OUTPUT="| tee -a $TMP_FILE "
         | sed 's/.*value="\([^"]*\)".*/\1/g'`;  else
           SAVE_DEBUG_OUTPUT=""
   fi
   
   #we now extract textarea name, which will be used later
   request=` $GET -P -H "Cookie: SITY=$COOKIE" \
           $WWW/\!u_sms.home $SAVE_DEBUG_OUTPUT \
           | awk -v number="$number" '
   BEGIN { printf "&SMSMsgLen=480&SMScount=&"; }
   /textarea cols/ {
           sub(/^.*name="/, "");
           gsub(/".*$/, "");
           printf "%s=%s&BT.x=0&BT.y=0&DETAIL=", $0, number;
   }
   /DETAIL/ {
           sub(/^.*value="/, "");
           gsub(/".*$/, "");
           printf "%s", $0 ;
   } '`
 echo 'Hold still, we need to wait 4 seconds.';  echo 'Hold still, we need to wait 4 seconds.';
 sleep 4;  sleep 4;
 # }}}  # }}}
Line 405  sleep 4;
Line 411  sleep 4;
 # Submitting SMS... {{{  # Submitting SMS... {{{
 echo 'Submitting SMS...';  echo 'Submitting SMS...';
 smss_left=`$GET -P -H "Cookie: SITY=$COOKIE" \  smss_left=`$GET -P -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""$request" \
         | grep "Tento mesiac" \          | grep "Tento mesiac" \
         | 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.";
   else
         if [ -z "$DEBUG" ]; then          if [ -z "$DEBUG" ]; then
                 rm -f $TMP_FILE;                  echo "Something went wrong, please use '--debug' option for debugging";
         else          else
                 echo "tmp file $TMP_FILE not removed for debug purposes!";                  echo "Something went wrong, tmp file $TMP_FILE not removed for debug purposes!";
         fi          fi
 else  
         echo "Something went wrong, see debug file ($TMP_FILE).";  
 fi  fi
   
   

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.40

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