I am just starting to learn python and using it with my raspberry pi and GPIO. I am trying to program this so it runs this line “echo p >> /home/pi/.config/pianobar/ctl” which would pause the song that is playing. I got it to print it but it doesnt actually pause the song.
#!/usr/bin/python
import os
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN)
while True:
mybutton = GPIO.input(11)
if mybutton == False:
print "pause"
os.system("echo 'echo 'p' >> /home/pi/.config/pianobar/ctl'")
time.sleep(.2)
and the output is: echo p >> /home/pi/.config/pianobar/ctl
pause
but nothing actually happens.
This line:
has two
echos, and the>>operator is quoted, so all it’s doing is printing something to standard output. Try: