Messente avatar logo

Send notification SMS from command line

- 5 MIN READ - 18 Oct 2012

Ability to send out notification SMS can be most invaluable to system administrators, as it allows to send urgent notifications to admins with ease.

Now there is a very easy way to send out notification SMS from unix command line. Using this guide and example bash script provided below, you can be up and running in less than 10 minutes.

1) Sign up on Messente.com

Go to https://messente.com/ and sign up. This takes up to 1 minute only.

Make sure you also verify your phone number, as this is required to send out SMS. When you skipped the number verification on sign-up flow, then you can add it later by selecting “+ Add Sender” from dashboard Sender selection drop-down menu.

2) Get your API username and password

First you need to know IP address of your server, where you are going to send out text messages. Find out your IP address from command line:

$ echo `curl -s http://automation.whatismyip.com/n09230945.asp`

Now go and get your API username and password from https://messente.com/apiaccount.

3) Get bash script

Save following script to a file, for example sendSMS.sh

#!/bin/bash
#set -x

# Configure this!
MESSENTE_API_USERNAME=00000000000000000000000000000000
MESSENTE_API_PASSWORD=11111111111111111111111111111111

# ---------------------------------------
# Do not modify anything below this line
# ---------------------------------------

if [ ! "$#" -eq 2 ]; then
 echo "ERROR 2 arguments required, $# provided"
 echo "-------------------------------------------------"
 echo "Usage: bash $0 full_phone_number text_message"
 echo "Example: bash $0 4463773683 "This is a test message""
 echo "-------------------------------------------------"
 exit 1
fi
echo -n "Sending SMS..."
curl -o /tmp/send_sms_result 
 -s http://api2.messente.com/send_sms/ 
 -d username=${MESSENTE_API_USERNAME} 
 -d password=${MESSENTE_API_PASSWORD} 
 --data-urlencode "to=$1" 
 --data-urlencode "text=$2"
API_RESULT=$( cat /tmp/send_sms_result | sed 's/( )(.*)/1/' )
API_RESULT_FULL=$( cat /tmp/send_sms_result )
if [ $API_RESULT == "OK" ]; then
 echo " done" 
 exit 0
else
 echo " failed (${API_RESULT_FULL})"
 exit 1
fi

4) Try out your new SMS sending function

You could make this file executable, or just call it directly:

$ bash sendSMS.sh 4463773683 "This is a sample text message"

And you are done! Now you can easily use this script to send out SMS messages

Troubleshooting

First, make sure you edited the script to include your personal API username and password.

Secondly, check the error code from Messente API documentation.

Still having troubles? Contact us development@messente.com and we will help you with it.

Jaanus Rõõmus

Jaanus Rõõmus - CTO

Jaanus is co-founder and CTO of Messente and makes sure its wheels keep spinning and Messente always has a full tank of fuel.

Startup Conferences: What’s the point? (Slush 2017)

20 Oct 2017

With Slush coming up in about a month, it’s a good time ponder the purpose of large startup conferences. Many entrepreneurs head to conferences, like Slush, around the world and throughout the year looking for investments from venture capitalists and angel investors, yet there’s a lot more to gain from startup conferences. Think about it: there will be over 17,000 motivated and creative people in one place at one time. Get creative and gain as much as you can out of the experience.

Yuriy Mikitchenko

Yuriy Mikitchenko

The economics behind undelivered, failed SMS messages    

17 Oct 2017

The cost and full impact of undelivered or failed messages isn’t immediately clear. The financial impact is not simply the combination of the failed SMS and the cost to resend the message, which isn’t very much at times. There are other indirect costs that result from undelivered SMS messages that matter from a financial perspective. Let’s take a deeper look into the ripple effect of undelivered messages, which make the reasons behind our focus on SMS delivery quality even more clear.

Here are a few examples.

Uku Tomikas

Uku Tomikas

Fraud and Security: 2FA Considerations for PSD2

10 Oct 2017

The second Payment Services Directive (PSD2) is less than three months away from enforcement. While the regulation’s text is lengthy, a key component of the law is its extended reach in comparison to the first directive. PSD2 applies to all payment service providers and affiliates, including account information service providers and payment initiation service providers. In addition, the law applies when at least one part of the transaction is in the European Union. This means that payment service providers and their affiliates outside of the EU must comply with the law when the payer is in the EU. The additional geographical reach guarantees the same level of security expectations for all EU residents regardless of the location of the payment service provider.

Raili Liiva

Raili Liiva

Start sending messages to

for € N/A

Contact us