Skip to content

Instantly share code, notes, and snippets.

@Lukse
Last active December 18, 2015 00:49
Show Gist options
  • Save Lukse/5699021 to your computer and use it in GitHub Desktop.
Save Lukse/5699021 to your computer and use it in GitHub Desktop.
Control remote Linux computer using DropBox (adapted for Carambola)
#!/bin/bash
# Prepare
# Install dropbox_iploader.sh script from https://github.com/andreafabrizi/Dropbox-Uploader
# Add [* * * * * /usr/bin/dropbox_action.sh] to crontab
# Usage
# Create file /remote/input.txt un your dropbox folder
# Put single line in this file to run in remote Caramola (without new line)
# Read result after minute or so in output.txt file
# Notes / Issues
# Don't use interactive commands.
# Enter single command
# Don't use new-line (\n) at the end of command
mkdir /tmp/remote
CMD=`dropbox_uploader.sh download /remote/input.txt /tmp/remote/input.txt 2>&1`
LINES=`wc -l "/tmp/remote/input.txt" | awk '{print $1'}`
OUTCOM=$(head -n 1 /tmp/remote/input.txt)
LEN=`expr "$OUTCOM" : '.*'`
if [ $LEN -gt 1 ]
then
$OUTCOM > /tmp/remote/output.txt
rm /tmp/remote/input.txt > /dev/null 2>&1
touch /tmp/remote/input.txt
CMD=`dropbox_uploader.sh upload /tmp/remote/input.txt /remote/input.txt 2>&1`
CMD=`dropbox_uploader.sh upload /tmp/remote/output.txt /remote/output.txt 2>&1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment