juxrez
Posts: 2
Joined: Sun Feb 15, 2015 9:18 am

Execute shell commands from a phyton script

Sun Feb 15, 2015 9:27 am

Hi, im working on a little task with Raspberry, the deal is: I need to do a Reset Button, not with the RUN pins, i need a script that execute a shell command when i press a button on GPIO pin. So, im not asking for code, just ideas to do the best way my little project. Thank you so much guys!
Have nice day!

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13142
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Execute shell commands from a phyton script

Sun Feb 15, 2015 11:51 am

the RUN pins ARE for attaching a reset button....
Press the reset/run button, and it resets, release the button and it runs.

also you are asking for a script, but not for code, but a script IS code.

juxrez
Posts: 2
Joined: Sun Feb 15, 2015 9:18 am

Re: Execute shell commands from a phyton script

Sun Feb 15, 2015 4:54 pm

mahjongg wrote:the RUN pins ARE for attaching a reset button....
Press the reset/run button, and it resets, release the button and it runs.

also you are asking for a script, but not for code, but a script IS code.
Im asking for wich function or metod is the best way to do this Job, as i said, im still learnig. Thanks again!

User avatar
Laurens-wuyts
Posts: 716
Joined: Wed Aug 21, 2013 7:35 pm
Location: Belgium
Contact: Website

Re: Execute shell commands from a phyton script

Sun Feb 15, 2015 4:58 pm

You can use Popen from the subprocess module.
https://docs.python.org/2/library/subpr ... onstructor

Laurens

Return to “Python”