I am puzzled as to why the following script (count.py) will not run using the IR remote
#!/usr/bin/env python
from __future__ import with_statement
with open('num.txt','r+') as f:
counter = str(int(f.read())+1)
f.seek(0)
f.write(counter)
I have other scripts which work fine i.e. this one when mapped to same button executes without issue
#!/usr/bin/env python
import RPi.GPIO as GPIO ## Import GPIO library
GPIO.setmode(GPIO.BCM) ## Use board pin numbering
GPIO.setup(22, GPIO.OUT) ## Setup GPIO Pin 7 to OUT
GPIO.output(22,True) ## Turn on GPIO pin 7
GPIO.cleanup()
The problem script will work from the command line using 'sudo python count.py' and if I start irexec from the command line with sudo then it will also run using the remote. In essence starting irexec in this way is a workable solution. Nevertheless I am still keen to establish why under the present conditions the script will not run.