1

I have a linux computer (ubuntu) at some remote location and some scripts to automate things. Then another script will check whether the tasks have been completed. The final step is where i am having problem because I would like to write a script that can send me a notification/alert/update on a web, which I can check later using my smartphone or a windows/linux computer. The script just have to output "Completed" or "Fail"

I have read on several approaches: using email, websockets, push notifications to smartphone and SSH. Is there anything that can be done from the linux terminal that can achieve this task?

SSH: I am having problem connecting to that pc from external network/remote location. Email: I do not prefer this approach because of the vulnerability of having my username and password in the script. Push notification on Smartphone & Websocket: I am still reading on this.

4 Answers 4

2

I made myself a notification system from Linux to smartphone using Pushbullet.

You have to:

  1. Install Pushbullet on your smartphone and create an account

  2. Using the same account, create a token on the Pushbullet API

  3. Create a script that using the token sends a notification. In bash it's as simple as this :

      curl --header 'Access-Token: <your_access_token_here>' \
           --header 'Content-Type: application/json' \
          --data-binary '{"body":"Space Elevator, Mars Hyperloop, Space 
          Model S (Model Space?)","title":"Space Travel Ideas","type":"note"}' \
          --request POST \
          https://api.pushbullet.com/v2/pushes
    

4 . You'll receive the notification on your smartphone through the Pushbullet app.

1
  • Thanks for the suggestion. I will definitely try it. However, if I would like to try to develop the system myself, instead of push notification to an app on smartphone, can it do update on a website instead? I am good at developing website but not so much on developing app.
    – goddar
    Jul 26, 2017 at 15:12
1

Someone recommended Pushbullet, which is a good option. Another is Simplepush. I use the simplepush Python module in a small Python script to send the push notifications to my device, but the simplepush repository on GitHub comes with a Bash script you can use instead. I prefer simplepush because it does not require authentication via Google. Another option that I haven't tried yet is wirepusher.

0

If the information "completed" or "fail" isn't very confidential, you could use a commandline chat tool. For example an XMPP client like mcabber. In this case you need a corresponding online account. Maybe take a look at mcabber.

To use email your username/password don't have to be necessarily inside your script. If you manage the linux server you may install an local mailserver (postfix, exim4, ...) and use the local mail command. But if someone else manages this server your password still resides (root) available in config file.

If you don't mind to purchase an additional (cellular) sim card, there is a possibility to send an WhatsApp message via commandline: see yowsup on github. As far as I remember the sim card must not have been used for any phone number before so it can be registered by the script. But you have to figure out yourself, because I just remember this project but never used by myself.
This is an article from the linux magazine which descibes the way to register the sim card. Maybe you have access to this magazine?

Hope this post is helpful to you ...

3
  • Thanks for the suggestion. For suggestion number 1, do you think it will encounter the same problem as SSH, as I stated above? When I was on the same network, I was able to SSH between the 2 computers. However, once I am outside the office building and using the internet at my home, I was not able to SSH to the computer at the office. So I was wondering if mcabber would be able to overcome that?
    – goddar
    Jul 26, 2017 at 14:24
  • I assume your office network is a private network behind router/firewall - from internet point of view. So routing inside this network is fine. If your home computer is not connected via VPNn nor the firewall/router supports port forwarding either, the home network does not know how to route the packages: no access to your server at all. If the mcabber client can connect to the internet sending notifications is possible.
    – ChristophS
    Jul 27, 2017 at 9:19
  • Is there any particular reason for recommending mcabber instead of other xmpp clients? I saw there are lots of them. Thanks.
    – goddar
    Jul 29, 2017 at 1:04
0

Install Termux on Android and run sshd in Termux.

Then you can ssh some Termux:API goodies like

termux-media-player play some.mp3

termux-notification --content finished

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .