shellraspberry-pixtermmagic-mirror

Open Multiple XTerm Windows Simultaniously


I am working on a Raspberry Pi powered Magic Mirror project and to start the program I execute a shell script that runs in the background continuously. To make the AI part of my project work I need to open a second shell script in the background that also runs continuously. My problem occurs when I try to execute my Xterm commands it waits for the first script to complete before it starts the second script. Since both scripts have no designated end point I am stuck. Is there a way to make both Xterm commands execute at the same time?

Here is my current code to start the Xterm sessions:

cd ~/MMStartAll

xterm -e "cd ~/MMStartAll; ./AssistantStart.sh"
xterm -e "cd ~/MMStartAll; ./MMStart.sh"

$SHELL

Solution

  • Your script should end with a &. This means that both the xterms will run in a sepperate process id (pid).

    cd ~/MMStartAll
    
    xterm -e "cd ~/MMStartAll; ./AssistantStart.sh" &
    xterm -e "cd ~/MMStartAll; ./MMStart.sh" &
    
    $SHELL