Issue running program after startup

I have a RaspberryPi 3 with a BrickPi 3, and I’m trying to build a lego robot that I can control with a Playstation 3 remote. I have performed the following steps, and I’m having issues getting my program to automatically run after startup.

  1. I connected the PS3 remote to the Raspberry PI (reference HowTo article); this was successful.
  2. Wrote a python program to change 4 EV3 LEGO motors, based on the PS3 values; this was successful.
  3. Then I tried to edit the “/etc/rc.local” file, to automatically run my program after startup (reference HowTo article). The following is what I entered in my rc.local, and I am not getting a log.txt file either.

sudo python /home/pi/Desktop/BattleBot/FlagBattleBot.py & /home/pi/Desktop/BattleBot/log.txt 2>&1

Any and all help is greatly appreciated.
Clint

Hi, try to add a path for a python command - have a look on /usr/bin/ and there python file (it’s a Link to executable). Also you may check the 1st location of python file (Link to executable) by: whereis -b python

Cheers,

Hi @c-spurgeon,

I suggest you get rid of the sudo python command and replace it with /usr/bin/env python.
I would also try to see if it works by adding a shebang in the python script and by making it executable.

There may be another elegant solution too and that’s possible through the use of SystemD, which is the new de-facto init system used in Raspbian.

There may also be a path issue, so maybe you need to check that out too.

Thank you!