I am on a Raspberry Pi, and I am using a program called fswebcam
, which allows you to take pictures with a webcam.
~$ fswebcam image.jpg
That command if entered in terminal takes a picture and saves it to your computer, however I want to build a simple python program that can access the terminal and execute that same command as I have listed above.
I have tried to import os
and use os.system('fswebcam image.jpg')
But it isn't working for me.
How can I have python execute terminal commands?
subprocess
module is preferred.os.system
usually uses the same shell but in non-interactive mode. So,fswebcam image.jpg
is a shell command, but it isn't related to terminal.type fswebcam
orcommand -v fswebcam
? (type the commands in the shell)