How to send/notify messages to iOS and Android from the Linux console

How to send/notify messages to iOS and Android from the Linux console

One of the essential tasks for developers and system administrators is to receive an alert notification about failed services or running out of disk space and other critical failures. Let’s see how to send or send a direct message to a mobile device powered by Apple iOS or Google Android.

How to send/notify messages to iOS and Android in real time.

We could (and will not) use the AWS SNS push notification service to send an alert directly to an application on a mobile device. However, today I will use a simple application service called pushover. It’s a simple app to get real-time notifications on Android, iPhone, iPad and desktop including Android Wear and Apple Watch. Let’s see how to use Linux to send notifications to an Android or iOS device.

Why send push notifications from the Linux CLI?

As a freelance developer and Linux sysadmin, I needed an easy way to get notified for my side projects using the API. I can get notified for failed backups or my Nginx service is overloaded due to issues or MySQL read only replica is out of sync. My search ended with Pushover. However, it is not a free service. To use Pushover for yourself or a small group, it’s just a one-time $5 purchase on each platform. You can send 7,500 messages a month, which is more than enough for my needs. They also have the option to send messages to a group of developers and IT teams. My criteria were simple:

  1. I needed support for my Perl, Python and bash/shell scripts.
  2. You need to push the notification to the iPhone.
  3. It shouldn’t be very expensive.

The Pushover service seems to meet all my requirements. Enough talk, let’s get our hands dirty with some examples.

Step 1: Sign up for Pushover

First download the pushover device clients:

  • android version
  • iOS version (iPhone, iPod Touch and iPad)

Be sure to sign up for the service or get a seven-day trial account. Once you’re logged in, register your cli application, set your name, and get an API token in return.

Step 2 – Create a Shell Script Wrapper API Script

Create a new shell script as follows:

We can simply use the sendmail command or the mail command in the following way from our shell scripts:

So far, the Pushover service and app have worked great for me. I can easily send/push messages to iOS and Android devices using Shell/Perl/Python scripts.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent News

Editor's Pick