Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone,

when executing this command in unix:

echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csv

It works fine, but running this command in a shell script gives an error saying that there's a syntax error.

here is content of my script:

tdbsrvr[Support]$ vi hc.sh
"hc.sh" 22 lines, 509 characters 
. oraenv
echo "Please Enter Username:"
read usrnm
echo "Please Enter Password:"
read pswd

sh que.sh $usrnm $pswd > query1.txt
sh que2.sh $usrnm $pswd > query2.txt
sh que3.sh $usrnm $pswd > query3.txt

echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csv
echo "WM7 Stuck Alarms:", $(cat query2.txt) > b.csv
echo "WM7 Active Files:", $(cat query3.txt) > c.csv

cat a.csv b.csv > 1.csv
cat 1.csv c.csv > 2.csv

echo "Please enter email address:"
read eadd

uuencode 2.csv 2.csv | mailx -s "Health Check" $eadd

upon executing this script by using "sh hc.sh", it gives me this error after inputting username and password:

tdbsrvr[Support]$ sh hc.sh
ORACLE_SID = [WM7TEST] ? WM7TEST
Please Enter Username:
wtest
Please Enter Password:
wtest
hc.sh: syntax error at line 11: `(' unexpected

Line 11 points to this command: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csv

So i tried running the command outside the script and it worked just fine. but running this script gives me a syntax error message regarding this command! HELP!
WHAT COULD BE WRONG??? PLEASE HELP ME!

Try

echo "WM7 Fatal Alerts:", `cat query1.txt` > a.csv

instead of

echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csv

try this:

echo "WM7 Fatal Alerts:",`cat query1.txt` > a.csv

ok will try that now. THANKS!

---------- Post updated at 06:17 PM ---------- Previous update was at 06:11 PM ----------

wow that worked FINE! THANK YOU SO MUCH BARTUS AND ROHON!

just in case.. try if the below one works..

echo "WM7 Fatal Alerts:, $(cat query1.txt)" > a.csv