Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SCRIPT] mini-frontend sotto kde per alicesms/tinsms
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Tue Jan 11, 2005 9:38 pm    Post subject: [SCRIPT] mini-frontend sotto kde per alicesms/tinsms Reply with quote

ho creato uno scriptillo per usare tinsms o alicesms in kde tramite le sue dialog (per la mia ragazza che non e' tanto pratica di shell :D)
Requisiti: kde, bash 3 (opzionale forse, ma preferibile) e ovviamente alicesms o tinsms, a seconda del contratto adsl che avete.

EDIT 112/01/04: small fix

principali caratteristiche (se cosi si possono chiamare):
  • Autocerca l'eseguibile nel path in base a quale dei 2 avete (se non lo specificate direttamente all'inizio dello script) (opzione autoscan (modificabile al volo come parametro in command line, vedi sotto) oppure usa uno dei due programmi se li avete installati (opzione tinsms o alicesms) o potete passargli direttamente il percorso all'eseguibile.
  • Auto-splitta i messaggi + grandi di 136 caratteri (configurabile,come sopra)
  • check (di base) sui prefissi e sui messaggi vuoti
  • Gira anche out-of-the-box senza configurazione

Per altre opzioni, usare -h

Non ha pretese di essere bug-free :)

Ecco lo script:
Code:
#!/bin/sh
# SMSme by Giovanni Ferri <giovanni@fonderiadigitale.it>
# simple kde wrapper for tinsms/alicesms
# This is GPL2 code.

#### modify these to suit your settings: ###
# if no program is specified, one will be
# searched under your $PATH.
#
#smsprogram="/usr/bin/tinsms"
tmpfile="/tmp/sms_output.log"
#
############################################

# start of functions

msg() {
   action=$1
   shift
   command="kdialog --caption SMSme --title \"${@}\""
   case ${action} in
      error)   eval "${command}" --error \"$@\"   ;;
      info)   eval "${command}" --msgbox \"$@\"   ;;
      box)    eval "${command}" --textbox ${tmpfile}   ;;
      ask)   eval "${command}" --inputbox \"$@\"   ;;
   esac
}

function asktowhom () {
   to=$(msg ask "Inserisci destinatario")
   checktowhom
}

function asktext () {
   message=$(msg ask "Inserisci testo dell'sms")
}

process_sms () {
   for ((n=0;n<${#msg[*]};n++));do
      ${smsprogram} ${to} "${msg[${n}]}" >> ${tmpfile}
      sleep 0.5
   done
   msg box
   rm ${tmpfile}
   exit
}

textinput () {
   asktext
   msgl=$(echo "${message}"|wc -c)
   if [ "${message}" == "" ]; then
      msg error "Il messaggio e' vuoto!"
      textinput
   else
      c=0
      charstart=0
      charend=122
      cc=$((msgl/122))
      if [ ${cc} -gt 0 ]; then
         [ $((msgl%122)) -gt 0 ] && ((cc+1))
      fi
      while [ ${c} -le ${cc} ];do
         msg[${c}]="${message:$charstart:$charend}"
         let charstart=charstart+122
         let charend=charend+122
         ((c++))
      done
      process_sms
   fi
}


checktowhom () {
       if [ "${to}" = "" ]; then
      msg error "Destinatario vuoto"
      asktowhom
       fi
       case ${to} in
               (333??????*|334??????*|335??????*|336??????*|338??????*|339??????*|330??????*|337??????*|360??????*|363??????*) textinput;;
      (368??????*|340??????*|346??????*|347??????*|348??????*| 349??????*|343??????*|328??????*|329??????*)       textinput;;
      (320??????*|323??????*|380??????*|388??????*|389??????*|390??????*|391??????*|392??????*|393??????*)       textinput;;
          *)   msg error "Numero del destinatario non corretto."; asktowhom ;;
       esac
}

to=""
message=""
smslength=136
progs="alicesms tinsms"

while [ "$1" ]; do
   case $1 in
      "-h"|"h"|"help")             echo "Usage: $0 [autoscan|alicesms|tinsms|/path/to/smsprogram] [length of sms message (default 136)]" ; exit;;
      "-alicesms"|"alicesms")             progs="alicesms" ;;
      "-tinsms"|"tinsms")                progs="tinsms" ;;
      "-autoscan"|"autoscan")             progs="alicesms tinsms" ;;
      [0-9]|[0-9][0-9]|[0-9][0-9][0-9])    smslenght=$1;;
      */*)                [ -x $1 ] && smsprogram=$1;;
   esac
   shift
done
   
if [ "${smsprogram}" == "" ] && [ "${progs}" != "" ]; then
   for prog in ${progs};do
      smsprogram=$(which ${prog} 2>/dev/null)
      if [ $? -eq 0 ]; then
         if [ -x ${smsprogram} ]; then
            echo -e "\nI've found ${smsprogram} under your \$PATH :)\n"
            break
         fi
      fi
   done
fi

if [ "${smsprogram}" == "" ] || [ ! -x ${smsprogram} ]; then
   msg error "No alicesms or tinsms found! Please check the path setting inside the script, or pass the right option on the command line."
   exit 1
fi

# start

set -a msg
asktowhom



bon divertimoont.
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
xchris
Advocate
Advocate


Joined: 10 Jul 2003
Posts: 2824

PostPosted: Wed Jan 12, 2005 8:20 am    Post subject: Reply with quote

non mi pare che giri sotto bash <3.

Code:

for ((n=0;n<${#msg[*]};n++));do


e' troppo CCCC :)
_________________
while True:Gentoo()
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Wed Jan 12, 2005 11:58 pm    Post subject: Reply with quote

:roll:
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Thu Jan 13, 2005 12:12 am    Post subject: Reply with quote

non esistono altri servizi? io ho fastweb :°
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Thu Jan 13, 2005 12:29 am    Post subject: Reply with quote

http://lists.linux.it/pipermail/annunci/2004-October/000305.html ho trovato questo sembra interessante
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Thu Jan 13, 2005 7:26 pm    Post subject: Reply with quote

Uppino ragazzi non c'è nulla cui rispondere volevo rendervi partecipi ma alle 2 di notte non credo abbia letto molta gente
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30966
Location: here

PostPosted: Thu Jan 13, 2005 7:33 pm    Post subject: Reply with quote

[MOD]Non serve neanche molto scrivere 3 post di fila!! Editate questi benedetti post invece di creare post inutili[/MOD]
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Thu Jan 13, 2005 7:49 pm    Post subject: Reply with quote

non ci avevo pensato :| però editando no viene segnalato come nuovo post per portarlo su bisogna postarne uno nuovo. (E' una bug di phpbb)
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum