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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mailx - include both specified text & external file text in body

Status
Not open for further replies.

Wrathchild

Technical User
Aug 24, 2001
303
US
I would like to include some standart text in the body of the email and then also redirect the contents of a file after the standard text.

This will include the standard text:
print "There was a problem executing the following SQL:" | mailx -s "$SQL_TYPE Failed" me@me.com

But when I try to add the file, none of the standard text is included in the email, just the external file shows:
print "There was a problem executing the following SQL:" | mailx -s "$SQL_TYPE Failed" me@me.com < SQL.sql

I realize I could add the standard text to SQL.sql to begin with, but I'm curious if it can be done this way.
 
Use brackets around some comamnds to join their stdout into stdin for mailx command like so:

(print "whatever"; cat SQL.sql)| mailx -s "subj line" addressee@domain.com


HTH,

p5wizard
 
Yet another way:
print "whatever\n$(<SQL.sql)" | mailx -s "subj line" addressee@domain.com

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top