[bash]récupérer un code de retour
Bonjour
J'ai développé sur bash v3.1.17 un script shell qui doit invoquer un certain programme:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
processExist(){
USER=$1
shift
JOB=$1
ps -fu $USER|grep -v grep|grep blastall|grep -c $JOB
RES=$?
if [ $RES -eq 1 ]
then
return 0
else
return 1
fi
}
##################MAIN PART#######################
RES=`echo $BLAST_CMD | tr -d \" | at now + \`at -l | wc -l\` min 2>> /dev/null`
while processExist $USER $JOB
do
sleep `perl -e 'print int(rand(100))'`
done
echo "update Job set endTime=now(), returnedCode=$RES where idJob=$JOB" > $TMP$JOB.sql
mysql -u $DBUSER -p$PASSWD -D BaseClearBLAST < $TMP$JOB.sql
rm $TMP$JOB.sql |
Ce code fonctionne donc sur mon shell. Toutefois, sur le shell du serveur (v2.05), le processus que je lance semble tourner en boucle ininterrompue.
Quelqu'un peut-il voir où je me suis planté ?
Merci d'avance.
@++