I hope you're having a great day and sorry about the title, I didn't know how to write it in a way everyone could understand what I'm stuck with.
So far, I have made this code (bash/linux):
RESEARCH=`find $DIRECTORY_NAME -type f -name "$PROGRAM_NAME[1-9]" -perm -ugo=x`
while [ #That's where I'm stuck (see below for explanation) ]
do
if [ #$PROGRAM_NAME[X] don't have an existing pid file ($PROGRAM_NAME[X].pid) ]
then
echo "Starting $PROGRAM_NAME[X]..."
./$PROGRAM_NAME[X]
echo "$PROGRAM_NAME[x] started successfully!"
else
if [ #Number of $PROGRAM_NAME < 9]
then
echo "Compilation of $NEW_PROGRAM[X]..."
gcc -Wall tp3.c -o $DIRECTORY_NAME/$NEW_PROGRAM[X]
echo "$NEW_PROGRAM[X] compiled with success!"
echo
echo "Starting $NEW_PROGRAM..."
./$NEW_PROGRAM[X]
echo "$NEW_PROGRAM[X] started successfully!"
else
echo "The number of process running is at its limit."
fi
fi
done
I think it's easy but I don't know how to do it ... What I want is to check if every $PROGRAM_NAME[X] (where X CAN range from 1 to 9) have an associated PID file. If not, start $PROGRAM_NAME[X].
So to do so, I think I must loop like Y time (where Y is the number of $PROGRAM_NAME[X] in DIRECTORY_NAME) and check them one by one...
For exemple, if I do ls $DIRECTORY_NAME, that would be like this :
prog1
prog1.pid
prog2
prog2.pid
prog3
prog4
prog4.pid
So I would like to start prog 3 and not create prog5 since not all element have a existing pid file.
Could anyone explain me more about the while condition?
Aucun commentaire:
Enregistrer un commentaire