View previous topic :: View next topic |
Author |
Message |
FonderiaDigitale Veteran
Joined: 06 Nov 2003 Posts: 1710 Location: Rome, Italy
|
Posted: Tue Jan 11, 2005 9:38 pm Post subject: [SCRIPT] mini-frontend sotto kde per alicesms/tinsms |
|
|
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 )
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 |
|
|
xchris Advocate
Joined: 10 Jul 2003 Posts: 2824
|
Posted: Wed Jan 12, 2005 8:20 am Post subject: |
|
|
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 |
|
|
FonderiaDigitale Veteran
Joined: 06 Nov 2003 Posts: 1710 Location: Rome, Italy
|
Posted: Wed Jan 12, 2005 11:58 pm Post subject: |
|
|
_________________ Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica
|
|
Back to top |
|
|
koma Advocate
Joined: 06 Jun 2003 Posts: 2702 Location: Italy
|
|
Back to top |
|
|
koma Advocate
Joined: 06 Jun 2003 Posts: 2702 Location: Italy
|
|
Back to top |
|
|
koma Advocate
Joined: 06 Jun 2003 Posts: 2702 Location: Italy
|
Posted: Thu Jan 13, 2005 7:26 pm Post subject: |
|
|
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 |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30966 Location: here
|
Posted: Thu Jan 13, 2005 7:33 pm Post subject: |
|
|
[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 |
|
|
koma Advocate
Joined: 06 Jun 2003 Posts: 2702 Location: Italy
|
Posted: Thu Jan 13, 2005 7:49 pm Post subject: |
|
|
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 |
|
|
|