A Bash script for sending telegram messages in Linux

Would it be nice to be able to receive notification from your Linux system in Telegram?

t_logo

I’ve come up with a rudimentary bash script which lets you integrate the telegram-cli into your own script which is useful for sending messages or notification within automated process to your Telegram account.

The bash script is very useful when you want to send notification to your Telegram account. Example usage: notifying you instantly whenever a backup has been completed or whenever somebody logged into your system or if there’s a brute-force attempt to log into your SSH. Basically anything that you can imagine!

First Step: Install telegram-cli

The first step is to install the telegram-cli client on your Linux system. You may choose to:

  1. Build it on your own – using source code, or
  2. Install telegram-cli from *.deb (Ubuntu LTS only)

IMPORTANT: Please read on how to initialize and sign-in the telegram-cli and key in the required telegram “CODE” in your phone.

Second Step: Copy send-telegram.sh script to /usr/local/bin

You may copy this telegram bash script and chmod it to be executed from command line (up to you).

Download the script at: https://blog.mypapit.net/upload/files/send-telegram.sh.txt

#!/bin/bash
######
###
# telegram-cli bash script r0.1
# change 'to' to your own  Telegram account name
# by =  Mohammad Hafiz bin Ismail  [mypapit@gmail.com]
# url=  https://blog.mypapit.net/
###
######

## Replace 'to' with your account name

to=Replace_this_with_your-Telegram_account_name
##


function show_usage {

 echo "Usage $0 [message]"
 exit
}




if [ $# -lt 1 ]
then
  show_usage
fi


telegram-cli -W -e "msg $to $1"

IMPORTANT: Do not forget to “chmod a+x” the “send-telegram.sh” script.
IMPORTANT: Change the “to” variable in the script to match your own Telegram username.

Third Step: Using the send-telegram.sh script

Using the send-telegram.sh is easy!

Once you’ve logged in and initialized your telegram-cli application. You only need to execute the “send-telegram.sh” to send instant messages to your Telegram account!

Just do this

wget -c https://blog.mypapit.net/upload/files/send-telegram.sh.txt
cp send-telegram.sh.txt /usr/local/bin/send-telegram.sh

Then chmod it, to make it executable,

sudo chmod a+x  /usr/local/bin/send-telegram.sh

IMPORTANT: Change the “to” variable in the send-telegram.sh script to match your own Telegram username.

sudo nano /usr/local/bin/send-telegram.sh

To test your telegram script, just make sure you’ve logged into Telegram and telegram-cli, and have entered the correct activation “CODE”. Read Step 1, if you are unsure.

Then you may try out the send-telegram.sh script

send-telegram.sh "this is my message"

To send telegram message with timestamp type:

send-telegram.sh "`date -I` : this is a message with timestamp"

What should I do next?

Use your imagination! You can integrate this script in crontab, or put it inside another another bash script or conditional operation, or even launch it from a web application, the potential is limitless.

Happy trying!

LILO Linux Bootloader project is ending

LILO – the venerable Linux Bootloader is ending its development. The news has been announced at its project’s page.

lilo-bootloader

I’ve used LILO since the very first time I’m acquainted with GNU/Linux operating system, back in 2002. LILO simplicity makes it easy to install and reinstall the bootloader using standard computer BIOS at the time.

However, guess time has changed, with multitude of the server environment which linux computer may have been deployed, LILO probably has caught up with its limitation.

Still, I could still see LILO can be useful within embedded computing environment.

Google Nexus 7 running on Ubuntu 13.04 Raring Ringtail

Here is the video showing Ubuntu 13.04 Raring Ringtail (still in development at this time of writing) running on Nexus 7, a 7.81″ tablet which runs Android Jelly Bean by default.

It is expected that more announcement will be made regarding Ubuntu tablet at the upcoming Ubuntu Developer Summit (UDS) in Denmark, which Mark Shuttleworth himself drop a hint that future Ubuntu development will focused on mobile platform. He even encouraged attendees to bring Nexus 7 to the summit.

My Thoughts
Its refreshing to see Ubuntu can be ported on tablets. It open up several opportunities to integrate Ubuntu operating system with mobile platform and together with the possibility of cloud computing, it will be able to unify the way people use their computers in their daily life. However, a new GUI has to be designed in order to make Ubuntu usable and convenient to be used on tablets.

All in all, it is a bold move from Canonical.

Early look on Ubuntu Friendly – Ensure the hardware you buy would supports Ubuntu!

Ubuntu Friendly is an initiative by Ubuntu community to ensure that desktops, laptops, netbooks are compatible with Ubuntu, hence “Ubuntu-friendly”. Ubuntu-Friendly depends on community participation to verify whether the hardware fully or partially supports Ubuntu, and rate its usability based on the core components tested.

When will it be available?
Ubuntu-Friendly will be available and integrated right into Ubuntu 11.10. Early adopters and testers can have access to it by Ubuntu 11.10 Oneric Beta 2 due to be released in mid-September.

The tool used for hardware testing is “Checkbox” which is accessible from the Live CD, under System Testing menu.

p/s: Visit Ubuntu Friendly page on Ubuntu Wiki, for more information.

Kudos to the Ubuntu community for coming up with this project, it’ll make life more easier in finding computers that fully support Ubuntu hardware!