launch
#!/bin/bash
# @author David BAILLY
# @date january 2012
# @brief Launches a serie of script in a specific order, memorizing the id and
# killing them at the end in the same order. In our case all the script are
# placed in folders each one containing a run.sh file.
wd=`pwd`
function launch
{
echo -e "launching $1..."
cd $1
#This is if you want each script to be executed in a different terminal
#~ incr=0
#~ gnome-terminal --geometry 80x20+600+0$incr --working-directory="$wd/$1" --title="$1" --command="./run.sh $2 $3 $4 $5 $6" &
#This is if you want to launch each script in the same terminal
./run.sh $2 $3 $4 $5 $6 &
cd ../
#For the placement of the different terminals
incr=$(($incr+50))
}
#saving the ID of already running scripts and bashs
# you need to put the name of your program in the grep to be sure it wont kill
# instances already running at the launch time
ps -A | grep 'promethe\|bpromethe\|run.sh' | sort -r | awk '{print $1 " " $4}' > psbeg.tmp
launch cerebellum $1 -S0 $2 $3 -b
sleep 1
launch transitions $1 -S0 $2 $3 -b
sleep 1
launch propriostates $1 -S0 $2 $3
sleep 1
launch striatum $1 -S0 $2 $3 -b
sleep 1
launch sensorimotor $1 -S1 $2 $3 -b
sleep 1
#~ launch vision $1 -S1 $2 $3 -b
#~ sleep 1
launch motor $1 -S1 $2 $3
sleep 1
#This script is launched without & at the end to make sure this script waits the
# end before to do anything
echo -e "debug"
cd debug
./run.sh $1 -W9 $2 $3
cd ..
#saving the ID of all running scripts and bashs
ps -A | grep 'promethe\|bpromethe\|run.sh' | sort -r | awk '{print $1 " " $4}' > psend.tmp
#looking for the one belonging to this experiment and saving it for kill.sh
diff psbeg.tmp psend.tmp | grep 'promethe\|bpromethe\|run.sh' >> kill.tmp
#we don't need those anymore
rm -f psbeg.tmp psend.tmp
#Call the kill.sh script to end all processes
#~ ./kill.sh
Pour ce script vous aurez besoin de télécharger également kill.sh.
Ce script un peu complexe sert à lancer d'autre script dans un ordre précis en sauvegardant les id des process ainsi lancés. Cela permet à la cloture d'envoyer des messages particulier au process concernés et des les fermer proprement ou encore les tuer si nécessaire.