-1

I am trying to run two different programs in xterm windows from the same automation script. My current code looks like this:

#!/bin/bash/sh
echo "STARTING PROGRAM ONE"

    # change into correct directory
    cd ~/myProjects/ProgramOne
    xterm -e myProg1 -a P1 &> /tmp/ProgramOne/P1.txt

echo "STARTING PROGRAM TWO"

    # change into correct directory
    cd ~/myProjects/ProjectTwo
    xterm -e myProg2 -a P2 &> /tmp/ProgramTwo/P2.txt

# Code to kill the xterm process?

echo "******************************************"
echo "START AUTOMATION COMPLETE"
echo "******************************************"   

What I am looking to accomplish is to have two separate programs, in different directories, run in two different xterm windows so I can demonstrate to the end user that the programs are running appropriately.

Currently, the first program executes fine, and when I Ctrl + C it, the second kicks off just fine. However, I would like both to execute at the same time.

I have looked at a few resources on SO but have not found anything to help me with this problem.

I am on a CentOS7 system, trying to automate this process. Any help or advice would be great.

Thanks!

artemis
  • 6,857
  • 11
  • 46
  • 99

1 Answers1

0

Start them in the background and wait for them to finish:

#!/bin/bash/sh
echo "STARTING PROGRAM ONE"

    # change into correct directory
    cd ~/myProjects/ProgramOne
    xterm -e myProg1 -a P1 &> /tmp/ProgramOne/P1.txt &

echo "STARTING PROGRAM TWO"

    # change into correct directory
    cd ~/myProjects/ProjectTwo
    xterm -e myProg2 -a P2 &> /tmp/ProgramTwo/P2.txt &

# Code to kill the xterm process?
wait

echo "******************************************"
echo "START AUTOMATION COMPLETE"
echo "******************************************"   
Poshi
  • 5,332
  • 3
  • 15
  • 32