Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cat Command Syntax Issue

Status
Not open for further replies.

Ati2ude

Programmer
Dec 11, 2001
79
US
I am trying to create an e-mail with an attachment during a cron job. My only option is sendmail, so that makes it more difficult. Below is the code I am using, the error I am getting is:

Error Text:

syntax error at line 251 : `<<' unmatched

Line 251 is the cat command, I am not sure what I am doing wrong.

Code:
cat << EOF > ./mailfile2
# Create Header of Log File for e-mail failure
echo "To: $to" >> $mailfile2;
echo "Reply-To: $to" >> $mailfile2;
echo "Subject: $subject" >> $mailfile2;
echo $sMime >> $mailfile2;
echo $sContent_Type_Text >> $mailfile2;
echo sBody >> $mialfile2;
echo $sBoundary >> $mailfile2;
echo $sContent_Type_File >> $mailfile2;
echo $sContent_Disp >> $mailfile2;
echo $Content_Encoding >> $mailfile2;
echo "New data" >> $mailfile2;
echo $sBoundary >> $mailfile2;
echo "Sending e-mail";
EOF
#send the mail
/usr/sbin/sendmail -f$from -t < $mailfile2 >/dev/null


Thanks in advance for any assistance,
Ati2ude
 
try it like this:

cat > ./mailfile2 <<EOF
To: $to
Reply-To: $to
[etc]
EOF

echo "Sending email..."
/usr/sbin/sendmail -f$from -t < $mailfile2 >/dev/null


Mike

"Deliver me from that bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Thanks, I am now getting the following error:

./cycle_mdreport.ksh[248]: syntax error at line 251 : `<<' unmatched

I have tried to adjust spacing of the cat statement, hoping that is what you meant Ken, if not a little more guidance would help.

Brian
 
That final EOF has to be:
[ul]
[li]Right at the beginnning of the line[/li]
[li]Be absolutely the only thing on the line (no trailing spaces)[/li]
[/ul]


Mike

"Deliver me from that bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Brian - Mike's expansion of my rather terse post says what I should have. Hope it's sorted now. Incidentally, in your first post, I assume:

echo sBody >> $mialfile2;

is a typo and mialfile2 should be mailfile2?

Cheers.
 
It was a typo, had to look at the code to make sure. So the EOF does not need a ";" after that line??? Just want to make sure I get that correct. Thanks again for all of your help.

Brian
 
Always happy to clean up after you Ken :)

Mike

"Deliver me from that bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Dunno what happened there with the double post, but your cleansing is much appreciated, Mike!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top