0

I need to open the terminal on startup and execute three commands in the same window automatically on my Raspberry 4B. The first is a cd command. The second one is: source /tflite/bin/activate. And the last one is: python program.py. After executing the last one, I need to keep the program running. I've tried solutions from similar threads like: this or this but none of them worked for me. I also tried making an sh file, which executed the commands separately and had some other issues (The python program was executed and was running in a loop (which was intended) but when it got a point when it had to run another program it did nothing although it normally works.). I've also modified the ~/.config/lxsession/LXDE-pi/autostart file, but it didn't work.

2
  • 1
    this or this you failed to actually link to anything Commented Jul 2, 2023 at 1:22
  • had some other issues ... please describe the issues
    – jsotola
    Commented Jul 2, 2023 at 2:20

1 Answer 1

0

It sounds like the issue is you want to run those command in a terminal. Put them in a script and then execute them from the LXDE autostart this way:

lxterminal -e /path/to/script

Note that this terminal will close when the script finishes, which should be okay if it starts a python program that loops. Otherwise, add bash to the end of the script to keep the terminal open.

It seems there are some caveats about using the per-user autostart file you should be aware of: https://forums.raspberrypi.com/viewtopic.php?t=294014

For more details about using the terminal see man lxterminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.