Skip to content
  • I propose you an enhanced version that launches samples and also closes automatically windows:

    #!/bin/bash
    
    ## associative array for job status
    declare -A JOBS
    results=""
    
    ## run command in the background
    background() {
      eval $1 & JOBS[$!]="$1"
    }
    
    ## check exit status of each job
    ## preserve exit status in ${JOBS}
    ## returns 1 if any job failed
    reap() {
      local cmd
      local status=0
      for pid in ${!JOBS[@]}; do
        cmd=${JOBS[${pid}]}
        wait ${pid} ; JOBS[${pid}]=$?
        if [[ ${JOBS[${pid}]} -ne 0 ]]; then
          status=${JOBS[${pid}]}
          results+=" - $cmd : ${RED}FAILURE${NC}\n"
        else
          results+=" - $cmd : ${GREEN}SUCCESS${NC}\n"
        fi
      done
      return ${status}
    }
    
    
    #to colorize output
    RED='\033[0;31m' #RED
    GREEN='\033[0;32m' #GREEN
    NC='\033[0m' # No Color
    BOLD='\033[1;37m'
    
    tutos=$(ls tuto*)
    tutos="${tutos}\n$(ls ex*)"
    
    echo -e "parsing tutorials:\n$tutos"
    
    for t in $tutos;do
        background ./$t
        sleep 2
        pkill sightrun
    done
    
    reap
    
    echo -e "\n------------------------------\n"
    echo -e "${BOLD}Results:${NC}\n\n$results"
    echo -e "\n------------------------------\n"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment