kemisten
Posts: 18
Joined: Tue Jan 09, 2018 10:55 am

total newbie to Linux/python/sh

Tue Jan 16, 2018 2:36 pm

i got a python script named "take_pic" that takes a picture with my cam and after take_pic is done i want to send "./dropbox_uploader.sh upload cam /Apps/PythonUploader" to terminal or if you can do it another way :roll:

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: total newbie to Linux/python/sh

Tue Jan 16, 2018 3:11 pm

You can run shell commands using the subprocess module (you can also use os.system but, as python recommend using subprocess instead, that's what I'm going to show you!).

One disclaimer: I don't know the dropbox uploader script so I will assume that the code you've got in your post is correct and complete.

Code: Select all

import subprocess

# Code to take your photo here

# Run uploader
subprocess.call(["./dropbox_uploader.sh", "upload", "cam", "/Apps/PythonUploader"])
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

Return to “Python”