Skip to main content

Thread: Send/receive SMS via android device.


hi,

have spare samsung gio android device.
on nas server have ubuntu server 12.04.2 installed.
i'm redirecting root mail e-mail on gmail using /root/.forward - works fine, , i'd keep that.
i'd add sending sms specified number(s) containing mail's subject and/or body (it nice have choice on send, eg. subject, or subject+body).

i'd make kind of remote controlling device phone.
eg. send sms: "nas:reboot", , it'll reboot machine (after checking sms came number that's on predefined whitelist).

best regards
szafran

ok. after hours (about 12 or ) of tests , research have working script sends sms messages.
script requires shellsms needs installed on phone (https://play.google.com/store/apps/d...aware.shellsms), , adb on pc.
scans directory *.sms files, , sends what's in them specified phone number using above apps.

script:
code:
#!/bin/bash  #wymaga zainstalowania shellsms na telefonie, podlaczenia przez usb wlaczenia debugowania usb   #parametry plik_ustawien="`dirname $(readlink -f $0)`/`basename $0`.settings" katalog_kolejki_smsow="/home/szafran/.scripts/smsy/kolejka" haslo_do_shellsms="1234567890"     #procedura usuwajaca biale znaki trim() {     local var="$1"   var="${var#"${var%%[![:space:]]*}"}"  # remove leading whitespace characters   var="${var%"${var##*[![:space:]]}"}"  # remove trailing whitespace characters   echo -n "$var"   } #trim       #glowna petla while :;     #odczytujemy ustawienia kopii zapasowych z pliku .settings   i=0   while read linia       linia=`trim "$linia"`     [[ "$linia" =~ ^#.*$ ]] && continue     [[ "$linia" == "" ]] && continue     settings[i++]="$linia"   done < "$plik_ustawien" #while read linia   unset   unset linia     nr_telefonu="${settings[0]}"   poczatek_ciszy_nocnej=${settings[1]}   koniec_ciszy_nocnej=${settings[2]}   main_sleep=${settings[3]}   night_sleep=${settings[4]}     unset settings     #sprawdzamy czy aktualna godzina jest poza ustawionymi godzinami ciszy nocnej   #jesli tak wysylamy smsmy, jesli nie pomijamy   aktualna_godzina=$( date +%h )     if [ $aktualna_godzina -lt $poczatek_ciszy_nocnej ] && [ $aktualna_godzina -gt $koniec_ciszy_nocnej ];       #sprawdzamy czy sa jakies smsy w kolejce wyslania - jesli tak interesuje nas tylko najstarszy plik     plik_kolejki=$( find "$katalog_kolejki_smsow" -type f -iname "*.sms" -printf '%t@ %p\n' | sort -k 1n | sed 's/^[^ ]* //' | head -n 1 )       if [ -n "$plik_kolejki" ];         tresc_wiadomosci=$( cat "$plik_kolejki" )       tresc_wiadomosci=$( trim "$tresc_wiadomosci" )       tresc_wiadomosci="${tresc_wiadomosci//$'\r'/$'. '}"       tresc_wiadomosci="${tresc_wiadomosci//$'\n'/$'. '}"         #wysylamy smsa z kolejki       wynik=$( adb shell startservice -a sendsms -n it.elaware.shellsms/.sms -e phonenumber "$nr_telefonu" -e smsbody "$tresc_wiadomosci" -e password "$haslo_do_shellsms" )         echo "$wynik" | grep -i -q "error"       if [ $? -ne 0 ];         rm -f "$plik_kolejki" &> /dev/null       fi #if [ $? -ne 0 ];       fi #if [ -n "$plik_kolejki" ];       unset plik_kolejki       #uspienie pomiedzy kolejnymi iteracjami petli glownej     sleep $main_sleep     else #if [ $aktualna_godzina -gt $poczatek_ciszy_nocnej ] || [ $aktualna_godzina -lt $koniec_ciszy_nocnej ];       #uspienie pomiedzy kolejnymi iteracjami petli glownej w czasie ciszy nocnej     sleep $night_sleep     fi #if [ $aktualna_godzina -gt $poczatek_ciszy_nocnej ] || [ $aktualna_godzina -lt $koniec_ciszy_nocnej ];   done #while :;   exit 0
.settings file:
code:
+48111222333 21 8 3 120
what needs setup use it:
katalog_kolejki_smsow - directory contains *.sms files (the sms queue)
haslo_do_shellsms - password setup in shellsms on phone

.settings file lines:
1: phone number including country code
2: night time hours start
3: night time hours end
4: day time script sleep seconds
5: night time script sleep seconds

script won't send messages dusring night time hours. send sms queue right after night time ends.
if name script file eg. "smssender" .settings file needs named "smssender.settings" , placed in same directory script.

, now, have idea on how achieve rest first post ?


Forum The Ubuntu Forum Community Ubuntu Specialised Support Ubuntu Servers, Cloud and Juju Server Platforms [all variants] Send/receive SMS via android device.


Ubuntu

Comments

Popular posts from this blog

Some mp4 files not displaying correctly (CS6)

Thread: Samba is not authenticating with LDAP