Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: autostart oled display failure..
#8
Well yes of course, if the Adafruit_Python_SSD1306 directory exists in /home/pi, adding ...

Code:
python ~/Adafruit_Python_SSD1306/raspberry-oled-monitor/monitor.py

... to rc.local won't work (nor will running this in a shell script run from rc.local) as commands run from rc.local are executed by root, root's home directory is /root.


Aside from that you shouldn't need a shell script at all, python scripts can be run just like other scripts so long as the interpreter is defined on the first line. The monitor.py script you have there has no #! to define an interpreter so you can add one.
Defining the interpreter as /usr/bin/python and making the script executable will allow you just run the script on it own.
Just insert...
Code:
#!/usr/bin/python
... as the first line of the monitor.py script and make the file executable.

Then you can run the script either as pi or root with...
Code:
/home/pi/Adafruit_Python_SSD1306/raspberry-oled-monitor/monitor.py

To append this to rc.local to run as root you'd do something like....
Code:
/home/pi/Adafruit_Python_SSD1306/raspberry-oled-monitor/monitor.py &

To run from rc.local as the pi user you can instead add...
Code:
/bin/su - pi -c "/home/pi/Adafruit_Python_SSD1306/raspberry-oled-monitor/monitor.py &"

If like you say the working directory needs to be script's location for the script to work you can do...
Code:
cd /home/pi/Adafruit_Python_SSD1306/raspberry-oled-monitor && ./monitor.py &


Hope that helps.
Reply


Messages In This Thread
autostart oled display failure.. - by DRONE7 - 12-27-2019, 11:54 PM
RE: autostart oled display failure.. - by DRONE7 - 12-28-2019, 03:20 AM
RE: autostart oled display failure.. - by vinnn - 12-28-2019, 11:47 AM
RE: autostart oled display failure.. - by DRONE7 - 12-28-2019, 04:57 PM
RE: autostart oled display failure.. - by DRONE7 - 12-30-2019, 03:59 AM
RE: autostart oled display failure.. - by vinnn - 12-30-2019, 06:10 AM
RE: autostart oled display failure.. - by DRONE7 - 12-30-2019, 06:56 AM
RE: autostart oled display failure.. - by vinnn - 12-30-2019, 08:03 AM
RE: autostart oled display failure.. - by DRONE7 - 12-30-2019, 08:26 AM
RE: autostart oled display failure.. - by DRONE7 - 12-30-2019, 08:57 AM
RE: autostart oled display failure.. - by vinnn - 12-30-2019, 09:39 AM
RE: autostart oled display failure.. - by DRONE7 - 12-30-2019, 10:02 AM
RE: autostart oled display failure.. - by vinnn - 12-30-2019, 10:30 AM
RE: autostart oled display failure.. - by DRONE7 - 12-30-2019, 10:44 AM
RE: autostart oled display failure.. - by vinnn - 12-30-2019, 10:53 AM
RE: autostart oled display failure.. - by DRONE7 - 12-30-2019, 08:11 PM
RE: autostart oled display failure.. - by DRONE7 - 12-31-2019, 03:24 AM

Forum Jump: