Crontab Not Running Dropbox Uploader

This problem is faced by nearly every Raspberry Pi user. You take a Raspberry Pi running at dwelling, and want to execute a command on it. The issue is, you lot are outside your home, on your mobile network, and have no way to admission your Pi. You can get a static IP address, or utilize one of the dynamic DNS services to enable access to your abode network. However, that is just too inconvenient for most people and takes too much effort for picayune gain. In addition, it opens your Raspberry Pi to brute-force attacks, since the SSH port is now exposed to the world.

The good news is, there is a more user-friendly, and more secure method – just email the commands yous wish to run on your Raspberry Pi. This way, all you demand is an email customer and a working net connection on your Pi. No logins, and no static IP's. What'southward more than, this method non only works with the Raspberry Pi, but with whatever Linux distro with the Bash shell and cURL installed. Sounds cool? Here is what you demand to prepare it up:

Requirements

  • A Raspberry Pi with a working cyberspace connection.
  • An account on IFTTT.com.
  • A Dropbox business relationship.

Getting Started

Set up IFTTT Recipe

We volition use IFTTT to distribute commands delivered by electronic mail to Dropbox. Afterwards setting up an IFTTT account, yous volition take to use the "Run bash commands on Raspberry Pi by e-mail" recipe. Only, go to this IFTTT recipe, and click on Add.

ifttt-recipe-to-run-commands-on-pi-by-email

Set Up Dropbox Uploader

We need Dropbox Uploadera command-line programme that can upload, download, list or delete files from Dropbox. Here is how to set it upward :

1. On your Raspberry Pi, get the prerequisite software ringlet and wget. Y'all probably already accept these installed, but we volition install them simply in example:

[sourcecode]sudo apt install wget curl[/sourcecode]

2. Create a folder where nosotros will set it up. Here, I've created a directory called raspi_email in my dwelling binder:

[sourcecode]mkdir ~/raspi_email
cd ~/raspi_email[/sourcecode]

three. Get the Dropbox Uploader script from GitHub, and mark it executable:

[sourcecode]wget https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/principal/dropbox_uploader.sh

chmod +ten ./dropbox_uploader.sh[/sourcecode]

4. Run the dropbox_uploader.sh script. You lot will encounter an output similar this:

dropbox-uploader

5. Now you need to create a Dropbox app. Log in to Dropbox, get to this URL, where you will see a screen that looks like this:

dropbox-api

half-dozen. As in the image above, start cull the Dropbox API, then select Full Dropbox in the blazon of access needed. Finally, Proper noun your app any you like.

7. Afterwards your new app is successfully created, scroll down to the OAuth2 department, and click on the Generate button to generate an access token. Y'all will now see a generated access token where the Generate button was. Copy this token, paste it in your final, and press Enter:

dropbox-uploader2

8. To verify that your business relationship is working, execute the command ./dropbox_uploader.sh list – you lot should run across a listing of the files in your Dropbox account.

Ready Raspi Runner

On your Raspberry Pi, download the Raspi Runner script in the raspi_email binder nosotros created previously:

[sourcecode] cd ~/raspi_email

wget https://raw.github.com/enkydu/Raspi_Runner/master/raspi_runner.sh[/sourcecode]

Make the script executable, and run information technology:

[sourcecode]chmod +x ./raspi_runner.sh

./raspi_runner.sh[/sourcecode]

Yous volition now meet a prompt like the image below. When the script asks for the full path to your Dropbox Uploader, enter the path to your Home directory (probably /home/pi/), followed by the name of the folder in which you downloaded the dropbox_uploader.sh script. If you followed this guide give-and-take by word, you will enter /home/pi/raspi_email here.

raspi-runner

Set up Crontab

Once the basics are in place, it is necessary to schedule the running of Raspi Runner. For example, you lot can set it to check for emails every 5 minutes.We will use crontab for this. On your Raspberry Pi, run:

[sourcecode]crontab -e[/sourcecode]

On the lesser of the file, add the post-obit line:

[sourcecode]*/5 * * * * /home/pi/raspi_email/raspi_runner.sh > /dev/null ii>&1[/sourcecode]

Of course, in the above example, supplant pi with your username, and raspi_email with the folder you placed the raspi_runner.sh script in. Now salve your crontab.

Usage

Merely send an email with the commands yous wish to execute on your Pi to trigger@recipe.ifttt.com from the email accost yous used to fix your IFTTT account. The body of the email will contain the command. You can add whatever subject you like to the email, but it is recommended that y'all exercise add one. In the following case, I am commanding my Raspberry Pi to shut downwards:

email

After the amount of filibuster you set in your crontab, the raspi_runner.sh will run and execute the command contained in your e-mail.

Encounter Besides: How to Set Up and Get Started with Raspberry Pi 3 (Starter Guide)

Run Commands Remotely On Your Raspberry Pi Using IFTTT

So this is how you lot tin use IFTTT, Dropbox, and some command line magic to run commands remotely on your Raspberry Pi. Of course, every bit mentioned in the get-go, this method will also work with any Linux or Unix-like system with the Fustigate shell installed.

Stay tuned for more Raspberry Pi tips and tricks in the future. If you have problem setting it upward, or want to share some of your own absurd IFTTT tricks with us, make sure to drop u.s.a. a line in the comments department below.

parsonlaisslange.blogspot.com

Source: https://beebom.com/how-to-run-commands-on-raspberry-pi-by-email/

0 Response to "Crontab Not Running Dropbox Uploader"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel