bashshellnotificationsubuntu-16.04notify-send

notify-send command issue in shell script


I have a text file b.txt with the following text:

notify-send -i gtk-info "How Are You" -h string:x-canonical-private-synchronous:anything

I have a shell script with the following code:

#!/bin/sh

while true;
do if [ -s b.txt ]
then
value="$(cat b.txt)"
exec $value
sleep 0.1
fi
done

When I run the script it throws the following error and notification is not displayed:

Invalid number of options.

But when the text file contains the command with just two words like this:

notify-send -i gtk-info "Hows You" -h string:x-canonical-private-synchronous:anything

the notification is displayed perfectly.

This issue is happening only when I execute notify-send through a shell script. How do I display a notification with a message having any number of words?


Solution

  • Try replacing exec $value with eval $value