How To Run Commands on Raspberry Pi by Email


This issue is confronted by almost every Raspberry Pi client. You have a Raspberry Pi running at home, and need to execute a charge on it. The issue is, you are outside your home, on your versatile system, and have no real way to get to your Pi. You can get a static IP address, or utilize one of the element DNS administrations to empower access to your home system. In any case, that is just excessively badly designed for a great many people and requires an excess of exertion for little pick up. Moreover, it opens your Raspberry Pi to savage constrain assaults, since the SSH port is currently presented to the world.

The uplifting news is, there is a more advantageous, and more secure technique – essentially email the charges you wish to keep running on your Raspberry Pi. Along these lines, all you need is an email customer and a working web association on your Pi. No logins, and no static IP’s. Besides, strategy works with the Raspberry Pi, as well as with any Linux distro with the Bash shell and cURL introduced. Sounds cool? Here is the thing that you have to set it up:

What should be the Requirements?

  • You need a Raspberry Pi with a neat and clean working internet facility or connection.
  • Second you must have an account on the
  • And last you must have an account on the Dropbox.

Getting Started

First you must understand the Shell script. So lets have a look at the Shell Script

What is a Shell Script?

A shell script is essentially a content record containing a progression of shell (order line) summons that are executed by the BASH shell. The shell peruses the script document and executes the orders one by one, as though they were information specifically on the summon line. This can spare time in the event that you have to execute numerous charges to finish an errand, since you should simply make a shell script and run it. Shell scripts permit you to robotize practically anything you can do on the Linux charge line.

The shell dialect is an abnormal state programming dialect. It is more expelled from framework and memory forms than lower level dialects. This essentially implies it has orders and capacities to perform undertakings that would some way or another take a ton of code to execute in lower level dialects like C or low level computing construct.

Shell scripts can make utilization of factors, if-then explanations, circles, and pipes.

What can a Shell Script do?

Shell scripts are incredible on the off chance that you have to enter long groupings of charges into the order line to accomplish something. Most operations can be proficient with a solitary charge on the off chance that you know how to compose a shell script for it. A few things they can be utilized to do:

  • Control what happens when the PC boots up
  • Begin applications when an occasion happens
  • Utilize the yield of one charge as the contribution for another order
  • Cluster rename and move records
  • Cluster change over record positions

One extremely helpful component of shell scripts is the capacity to make channels. A pipe permits the yield of one order to be sent to the contribution of the following summon. Channels can be utilized with the same number of summons as you need. The essential language structure for a pipe is:

command 1 | command 2

Now we will see the setup of IFTTT.

Set Up IFTTT Recipe

We will utilize IFTTT to disseminate orders conveyed by email to Dropbox. Subsequent to setting up an IFTTT account, you will need to utilize the “Run bash commands on Raspberry Pi by email” recipe. Just, go to this IFTTT formula, and tap on Add.


Set Up Dropbox Uploader

We require Dropbox Uploader – a charge line program that can transfer, download, list or erase documents from Dropbox. Here is the means by which to set it up :

  1. On your Raspberry Pi, get the essential programming cURL and wget. You most likely as of now have these introduced, yet we will introduce them to be safe:

1|sudo apt install wget curl

  1. Make an directory where we will set it up. Here, I’ve made a registry called raspi_email in my home organizer:

1 | mkdir ~/raspi_email

2 | cd ~/raspi_email

  1. Get the Dropbox Uploader script from GitHub, and check it executable:

1 | wget

2 |

3 | chmod +x ./

  • Run the script. You will see a yield this way:


  • Presently you have to make a Dropbox application. Sign into Dropbox, go to this URL, where you will see a screen that resembles this:


  • As in the picture above, first pick the Dropbox API, then select Full Dropbox in the sort of get to required. At long last, Name your application whatever you like.
  • After your new application is effectively made, look down to the OAuth2 segment, and tap on the Generate button to produce a get to token. You will now observe a produced get to token where the Generate catch was. Duplicate this token, glue it in your terminal, and press Enter:


  • To confirm that your record is working, execute the charge.

./ list- This will display a list of the files that are in your dropbox account.

Set Up Raspi Runner

On your Raspberry Pi, download the Raspi Runner script in the raspi_email envelope we made already:

1 | cd ~/raspi_email

2 |

3 | wget

Now you would have to make this script to be executable and then run it.

1 | chmod +x ./

2 |

3 | ./

You will now observe an incite like the picture underneath. At the point when the script requests the full way to your Dropbox Uploader, enter the way to your Home catalog (most likely/home/pi/), took after by the name of the directory in which you downloaded the script. In the event that you took after this guide word by word, you will enter/home/pi/raspi_email here.


Set Up Crontab

Once the rudiments are set up, it is important to plan the running of Raspi Runner. For instance, you can set it to check for messages each 5 minutes.We will utilize crontab for this. On your Raspberry Pi, run:

1 | crontab –e

After this you have to add the following line at the botton of the file.

1 | */5 * * * * /home/pi/raspi_email/ > /dev/null 2>&1

Obviously, in the above case, replace pi with your username, and raspi_email with the organizer you set the script in. Presently spare your crontab.


Essentially send an email with the orders you wish to execute on your Pi to from the email deliver you used to set up your IFTTT account. The body of the email will contain the order. You can add whatever subject you jump at the chance to the email, yet it is prescribed that you do include one. In the accompanying case, I am summoning my Raspberry Pi to close down:


After the measure of postpone you set in your crontab, the will run and execute the order contained in your email.