shell script result to file

Since I'm not an expert in shell scripting, I have question on sending script result to file. I have script like this...

if condition=0: then
echo "service is not running" | mail -s "Server Status" uname@companyname
fi
sleep 10
if configtion=1: then
echo "service is not running" | mail -s "Server Status" uname@companyname
fi

else
echo "service is running" | mail -s "Server Status" uname@companyname
fi

script is working fine but getting 3 mails from the server.

Instead sending 3 emails, I want to put all 3 in 1 file, send an email with attached file. Any idea.

Thanks

Before sending mail, put all your statements into one file and then cat the file. Try the following.....

if condition=0: then
echo "service is not running" > Result
fi
sleep 10

if configtion=1: then
echo "service is not running" >> Result
fi
else
echo "service is running" >> Result
fi

mailx -s "SUBJECT" uname@companyname << !END_OF_MSG

`cat Result`

!END_OF_MSG

Thanks for the quick reply.

mailx -s "SUBJECT" uname@companyname << !END_OF_MSG

`cat Result`

!END_OF_MSG

when i try this, I got `cat Result` in the mail eventhough there is file.

I tried this...

cat Result mailx -s "SUBJECT" uname@companyname << !END_OF_MSG

then i dont see anything in the mail. but when i ran just out side the script, it works fine.

Any idea. Thanks

---------- Post updated at 10:55 AM ---------- Previous update was at 10:23 AM ----------

it works fine. I think it was my mistake.

to make it just look good in the email, i want to have as it is in the file (one result in one line). But in the email I see all line are combined. Can we do it seperate line in the email. Thanks

These are left sloping quotes , not single quotes.

`cat Result`