SliTaz SliTaz Forum archive

This forum is now a read-only archive

The SliTaz community has moved to Maille, a forum made for SliTaz.

We looked hard for a replacement for this aging forum, including a move from bbPress to FluxBB last June. But spam bots now get through sign-up even with mail confirmation, and these forum engines are barely maintained anymore. So we wrote a forum in the SliTaz spirit: small, fast, no JavaScript, works on old machines and in text browsers. Everything here stays readable.

Go to Maille

You are not logged in.

#1 2016-10-26 19:22:23

gibor
Moderator
Registered: 2011-04-30
Posts: 1,067

Notify-Sms monitor per internet key

Semplice script per tenere sotto controllo l'arrivo di nuovi messaggi dalla chiavetta internet.

L'avviso compare a schermo tramite libnotify, che è già compreso in tutte le versioni di SliTaz.

Qui sotto il testo dello script. Salvatelo e rendetelo eseguibile, poi fatelo avviare in automatico al login.

Pochissime le risorse impiegate, ed molto utile per chi come me si collega con delle internet key, allo scopo di tenere sotto controllo tutti gli avvisi sull'abbonamento del provider.

Unica nota: il modem nello script è /dev/ttyACM1. In caso di differenze con il vostro, basta modificare quella voce.

Il refresh avviene ogni 60secondi, e anche quel valore si può modificare a proprio piacimento.

[attachment=43431,2384]

#!/bin/bash

# Script per il monitoraggio degli sms in arrivo su chiavetta internet

# uscita a schermo su notify-send, previo lancio di notification-daemon

# liberamente utilizzabile e modificabile da chiunque

# Author Gibor 26-10-2016

while : ; do

MODEM="/dev/ttyACM1"

SMS='AT+CMGL="ALL"'

function get_response

{

        local ECHO

        # cat will read the response, then die on timeout

        cat <&5 >$TMP &

        echo "$1" >&5

        # wait for cat to die

        wait $!

        exec 6<$TMP

        read ECHO <&6

        if [ "$ECHO" != "$1" ]

        then

                exec 6<&-

                return 1

        fi

        read ECHO <&6

        read RESPONSE <&6

        exec 6<&-

        return 0

}

function notify

{

    text=[c]cat $TMP | grep -A 1 "REC UNREAD" | grep -v "REC UNREAD"[/c]

    notify-send -t 0 'Hai un nuovo messaggio!' "$text" --icon=dialog-information

}

TMP="./response"

# Clear out old response

: >  $TMP

# Set modem with timeout of 5/10 a second

stty -F "$MODEM" 9600 -echo igncr -icanon onlcr ixon min 0 time 5

# Open modem on FD 5

exec 5<>"$MODEM"

get_response "AT+CMGF=1" || echo "Bad response"

get_response $SMS || echo "Bad response"

var=$(cat $TMP | grep "REC UNREAD")

if [ "$var" != "" ]; then notify; fi

exec 5<&-

# tempo di intervallo fra una rilevazione e l'altra

sleep 60

done

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.016 seconds, 7 queries executed - Memory usage: 1.54 MiB (Peak: 1.77 MiB) ]