4

I've installed AlexaPi onto my Pi 3 running Debian. I currently have to open 3 terminal tabs and run 3 commands to start Alexa. I'm trying to create a start up file so these load on boot.

I've tried following the feedback from this question. But I'm not sure how to write the commands in the file.

The commands I'm trying to run are:

~TAB1-Run Listen Script~

 cd ~/Desktop/alexa-avs-sample-app/samples 
 cd companionService && npm start

~TAB2-Initiate Alexa Script~

cd ~/Desktop/alexa-avs-sample-app/samples
cd javaclient && mvn exec:exec

~TAB3-Run Wake Word~

cd ~/Desktop/alexa-avs-sample-app/samples
cd wakeWordAgent/src && ./wakeWordAgent -e sensory

If someone is able to explain or provide a script on how to achieve this it will be greatly appreciated as I'm trying to learn.

Many thanks

Andy

Andy14
  • 41
  • 1
  • 5

1 Answers1

2

Based on the information you have provided. I recommend you try the following steps:

  1. Execute the following commands in a single terminal window:

    cd ~Desktop/alexa-avs-sample-app/samples/companionService
    npm start &
    cd ~/Desktop/alexa-avs-sample-app/samples/javaclient
    mvn exec:exec &
    cd ~/Desktop/alexa-avs-sample-app/samples/wakeWordAgent/src
    ./wakeWordAgent -e sensory &
    
  2. If step one works. Then create the following script file using your favorite text editor (e.g. nano, vi, geany, are some options):

    #!/usr/bin/sh
    cd ~Desktop/alexa-avs-sample-app/samples/companionService
    npm start &
    cd ~/Desktop/alexa-avs-sample-app/samples/javaclient
    mvn exec:exec &
    cd ~/Desktop/alexa-avs-sample-app/samples/wakeWordAgent/src
    ./wakeWordAgent -e sensory &
    
  3. Now follow the instructions in the Execute script on start-up question and you should be good to go.

Here are some more details explaining what each step above is doing:

  1. Step one is testing the assumption that all three commands can be executed in the background. It also combined and simplified the change director commands (cd) into a single cd command. There is no reason to visit the parent directories on the way to the final destination. The ampersand at the end of the commands tells linux to execute the commands in the background and not wait for the program to end before doing the next task. This is very important when creating scripts to be run at startup. Otherwise the startup process could get stalled waiting for a program to end that won't.

  2. In the second step we create what is called a script file. The first line tells the linux operating system which language to use to understand the script. In this case, we are using sh which is the program used to run commands from a terminal window.

    If you need help learning how to write commands into a script file, try searching for tutorials on the various text editors. Here is one for the nano editor: http://www.raspberrypi-spy.co.uk/2013/11/quick-guide-to-nano-text-editor-on-the-raspberry-pi/

  3. The third step provides information on having the RPi run your script on startup.

Daddy the Runner
  • 391
  • 2
  • 10