From 1388a4fbaeb2d590e084f686fe98246b5e7cc91f Mon Sep 17 00:00:00 2001 From: Dmitri Popov Date: Thu, 29 Mar 2018 10:19:44 +0200 Subject: [PATCH] Run shell command as subprocess --- rc/rc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rc/rc.py b/rc/rc.py index 2d9c861..5152b0f 100755 --- a/rc/rc.py +++ b/rc/rc.py @@ -14,7 +14,7 @@ # along with this program. If not, see . from bottle import post, route, request, template, static_file, run -import os +import os, subprocess @route('/') @route('/', method='POST') @@ -23,16 +23,16 @@ def remote_control(): free_home = "%.2f" % float((st_home.f_bavail * st_home.f_frsize)/1.073741824e9) if (request.POST.get("cardbackup")): - os.system("sudo /home/pi/little-backup-box/scripts/card-backup.sh") + process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/card-backup.sh", shell=True) return ('Backup started. You can close this page.') if (request.POST.get("camerabackup")): - os.system("sudo /home/pi/little-backup-box/scripts/camera-backup.sh") + process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/camera-backup.sh", shell=True) return ('Backup started. You can close this page.') if (request.POST.get("devicebackup")): - os.system("sudo /home/pi/little-backup-box/scripts/device-backup.sh") + process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/device-backup.sh", shell=True) return ('Transfer started. You can close this page.') if (request.POST.get("shutdown")): - os.system("sudo shutdown -h now") + process = subprocess.Popen("sudo shutdown -h now", shell=True) return ('Shutdown request sent. You can close this page.') return template('rc.tpl', freespace_home=free_home)