[Gllug] pipe data to mail body
Pete Ryland
pdr at createservices.com
Fri Feb 27 16:48:43 UTC 2004
On Fri, Feb 27, 2004 at 04:30:57PM +0000, ben f wrote:
>
> > You can run the various things you want concatenated
> > in a subshell, then
> > send the output from that subshell to mail, like
> > this:
> > -----
> > (echo Subject: stuff
> > echo
> > head -1 $log | awk '{print $1}'
> > awk -f ~/sh/myextract.awk $log
> > cat ~/.sig ) | mail -s 'test' root
> > -----
>
> Rich,
>
> This was just the sort of construct I needed - thanks.
>
> Couple of things:
> 1. Did you mean to put an echo in front of the "("
> starting the subshell to feed it through the pipe?
> I had to do this!
Not unless you have backticks or, equivalently, double parentheses.
> 2. One side-effect is that the shell eats my newlines.
> Is there a way to prevent the shell doing this?
Get rid of your echo. It will have this effect since it is treating all
that stuff as multiple whitespace-delimited arguments. :-)
Pete
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list