1

I am working with a raspberry Pi, and what I need is to make it launch scripts at startup when internet connection is active. I found a solution by setting instructions to be launched in the file below:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

Here are all the instructions I tried to set in the autostart file :

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@ngrok http 888
@cd ~/Desktop/app
@git checkout master
@git pull origin master
@ruby /home/pi/Desktop/app/script1.rb some_argument
@python3 /home/pi/Desktop/app/script2.py
@xscreensaver -no-splash

My issue is that ngrok instruction, and both python and ruby scripts are executed. However, something is not working with the git pull, and therefore, both ruby and python scripts that should be updated with the git pull are not.

My other issue is I do not know how to test this properly other than just rebooting the raspberry, and looking at the results of my scripts to see if the most current version of the scripts was executed or not.

Anyone knows how I could correct this issue, or how I could test ? I tried "startx" but I get the error below: parse_vt_settings: Cannot open /dev/tty0 (permission denied)

Any help ? Thanks a lot !

1

1 Answer 1

1

Autostart runs each command separately, not consecutively like a bash script.

In other words, cd will have no effect on subsequent commands. I suggest you stick all your commands in a bash script, and then have autostart run the script.

4
  • I did that and it works now, thanks ! Any insight on how to test autostart scripts other than just rebooting everytime ?
    – Ouhbelle
    Jan 13, 2020 at 17:19
  • @Ouhbelle, do you mean, "how to run /etc/xdg/lxsession/LXDE-pi/autostart" without rebooting? If so, IDK.
    – Botspot
    Jan 13, 2020 at 19:26
  • By the way, if my answer has helped you, feel free to accept it.
    – Botspot
    Jan 13, 2020 at 19:28
  • You could exit Xorg with Ctrl+Alt+F1, then in the console run startx. In that case the autostart script would be run without shutting completely down.
    – Botspot
    Jan 13, 2020 at 19:30

Your Answer

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

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