The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 08-03-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The <<HERE is a feature of the shell; you need to spawn a shell to get it working.

Code:
sprintf (cmd, "sh -c 'elm -s SUBJECT %s <<HERE\n"
  "%s\n[include %s text/plain base64]\nHERE\n'"l, emailAddr, sMailBody, sFileName);
You are not allowed any leading whitespace on the line containing the terminating HERE (at least not in many shells).

Couldn't you just open a pipe to "elm -s SUBJECT %s" with popen() and pipe in the content yourself, though? That's pretty much equivalent to using a HERE document. (And you avoild the pesky security considerations you always bump into when spawning a shell with user-supplied input.)

If the file truly is text/plain, what's the benefit of encoding it in base64, by the way?