Zenity and the script to send SMS (update)
Submitted by Pawel on 16 March, 2011

This is in addition to the script provided by Diamondcard used to quickly send SMS messages through this service.

Diamondcard - https://www.diamondcard.us/ - supports payment for calls computer-to-phone using the SIP protocol in instant messaging such as Ekiga or Twinkle QuteCom. It also allows, among other things, phone-to-phone calls in call back service and send SMS in various ways - including through its website and via Perl script available on its wiki page - http://wiki.diamondcard.us/podwiki?page=SendSms

Direct link to the script - http://sms.diamondcard.us/doc/sendsms.pl The script requires that you have Perl and SOAP module - in the Ubuntu repository as a package libsoap-lite-perl and its dependencies. The script should be saved to a file in your home directory in the directory bin/ and, of course, you have to give it the right to execute.

Here is a simple bash script using zenity:

#!/bin/bash
do=$(zenity --title "SMS" --text "SMS To:" --entry);
if [ "$?" == "1" ]; then
exit 0 ;
else
text=$(zenity --text-info --editable --title "Message" --width 300 --height 160);
sendsms.pl --verbose --accountid=XXXX --pin=YYYY --from=ZZZZ --to="$do" --msg="$text" > .not ;
not=$(cat .not) ;
zenity --info --text "$not" ;
fi
Here is a recommended script supporting list of contact:
#!/bin/bash
kon=$( cat kontakty );
zenity --list --text "List of SMS contacts" --width=290 --height=350 --checklist --column "Send" --column "Number" --column "Name" --separator="," \
FALSE $kon > .numery ;
if [ "$?" == "1" ]; then
exit 0 ;
fi
do=$( cat .numery );
zenity --text-info --editable --title "Message to $do" --width 500 --height 160 > .tresc ;
zenity --question --title "Sending SMS to $do" --text "Send SMS?"
if [ "$?" == "1" ]; then
exit 0 ;
else
text=$( cat .tresc ) ;
sendsms.pl --verbose --accountid=XXXX --pin=YYYY --from=ZZZZ --to="$do" --msg="$text" > .not ;
not=$(cat .not) ;
zenity --info --text "$not" ;
fi

It creates a hidden temporary files to the selected number .numery and with the message text .tresc

I have an additional script that adds contacts to the list. We provide a telephone number and a description with the space between:

#!/bin/bash
nowy=$(zenity --title "SMS contacts" --text "Add new number" --entry); 
if [ "$?" == "1" ]; then
exit 0 ;
else
echo ""$nowy" \\" >>  kontakty ;
fi

Adding the contacts.

It creates a file with the contacts.

Notes
Recommend activator on the desktop or the panel. In place of XXXX enter your ID, in place of YYYY pin that you receive after registering in diamondcard.us. In place of the ZZZZ enter your phone number (unless expect an answer). You can send messages to multiple recipients at the same time (in the first script, the numbers must be separated by a comma).

Note: service support phone numbers without the "00" or "+" at the beginning - that is, they should be starting with the number of the country (eg for Polish "48 ...").

This shell script with a text interface These requirements are the same as for the previous script - except zenity, of course.


#!/bin/bash
echo "CHOOSE NUMBER"
echo "========================"
echo "1. 123456789 Kumpel \\
2. 789456123 Kolega \\
3. 963852741 KtoĊ› \\ "
read N
case $N in
"1") echo "123456789" > .numer ;;
"2") echo "789456123" > .numer ;;
"3") echo "963852741" > .numer ;;
"q") exit ;;
esac
num=$(cat .numer) ;
echo "Number $num is chosen. Write text" ;
read tekst
echo " This is the message:"
echo "=================="
echo "$tekst" 
echo "=================="
echo "Send? y/n";
read odp
if [ "$odp" == "n" ]; then
echo "BYE" ; exit 0;
elif [ "$odp" == "y" ]; then
exec /home/pawel/bin/sendsms.pl --verbose --accountid=XXXX --pin=YYYY --from=ZZZZ --to="$num" --msg="$tekst" ;
echo "$@"
else
echo "Wrong answer: y/n"
fi


And this is a simple script that you can use when sending a message to someone who is not on the list and we have no intentions to put him on the list.

#!/bin/bash
echo "CHOOSE NUMBER"
read num
echo "Number $num is chosen. Write text." ;
read tekst
echo " This is the message:"
echo "=================="
echo "$tekst" 
echo "=================="
echo "Send? y/n";
read odp
if [ "$odp" == "n" ]; then
echo "BYE" ; exit 0;
elif [ "$odp" == "y" ]; then
exec /home/pawel/bin//sendsms.pl --verbose --accountid=XXXX --pin=YYYY --from=ZZZZ --to="$num" --msg="$tekst" ;
echo "$@"
else
echo "Wrong answer: y/n"
fi