Spaces in variables

I'm having a problem with this....

---------------------------------------------------

#!/bin/bash

SPKTAG=" | festival --tts"
echo "Welcome to my shell program" "$SPKTAG";

---------------------------------------------------

I have a variable call SPKTAG " | festival --tts" and I want to be it executable.

festival is a speaking program and the command line works like this:

echo "Welcome to my shell program" | festival --tts;

but I want the " | festival --tts" to be a variable so I can turn it off or on.

Any ideas?

Cheers
DV

It does not work that way - $SPKTAG is printed ONLY. Because echo expects to read literal characters and expanded variables and print them to stdout.

You have to put the | symbol outside of quotes to make the shell pipe the output of echo into your variable as an executable.

# speech on
SPKTAG=" festival -tts"
echo "something" | $SPKTAG
#speech off
SPKTAG= "cat -"
echo "something" | $SPKTAG

Cheers

Sorted!