So here is my solution:
First I write incoming command to a file called task:
mosquitto_sub -h SERVER -t '/TOPIC/' >> task
then I read the file, and execute the last command:
NUMOFLINES=$(wc -l < task)
while :
do
NEWLINE=$(wc -l < task)
if [ "$NEWLINE" -gt "$NUMOFLINES" ]
then
NUMOFLINES=$(wc -l < task)
LASTCOMMAND=$(tail -n 1 task)
eval ./$LASTCOMMAND
fi
done
the Message of the topic equals the file name to execute.
This is working just fine for me