<div dir="ltr">Good idea. Thanks!<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 21, 2014 at 2:42 PM, Chris Craig <span dir="ltr"><<a href="mailto:kwlug.org@ciotog.net" target="_blank">kwlug.org@ciotog.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You could put your commands in a function, then call the function in<br>
the subshell call.<br>
<div><div class="h5"><br>
On 21 August 2014 12:35, Khalid Baheyeldin <<a href="mailto:kb@2bits.com">kb@2bits.com</a>> wrote:<br>
> For years I have been using the following technique to capture output<br>
> (stdout and stderr), for emailing the results.<br>
><br>
> (<br>
> command<br>
> command<br>
> if [ ....<br>
>   command<br>
> else<br>
>   command<br>
> fi<br>
> ...<br>
> ) 2>&1 > /tmp/logfile<br>
><br>
> Basically, the () is a subshell, and its output is captured.<br>
><br>
> Then the logfile can be kept or sent via email from the same script, often<br>
> conditionally if there are errors e.g.:<br>
><br>
> mail -s "script output" <a href="mailto:me@example.com">me@example.com</a> < /tmp/logfile<br>
><br>
> The only thing that is annoying is that vim syntax highlighting gets thrown<br>
> off for the stuff in between the ().<br>
><br>
> Anyone knows of a way around this? Either alternates to capturing output<br>
><br>
> I thought about the script command:<br>
><br>
> script -c myscript /tmp/logfile<br>
><br>
> But then I have to break every script into two files, one a wrapper that<br>
> runs the real script and emails its output and the script proper itself.<br>
> Also, it annoyingly captures everything like terminal escape codes and such.<br>
><br>
> Another approach is to fix vim syntax highlight, but I don't know how.<br>
><br>
> Any ideas?<br>
> --<br>
> Khalid M. Baheyeldin<br>
> <a href="http://2bits.com" target="_blank">2bits.com</a>, Inc.<br>
> Fast Reliable Drupal<br>
> Drupal optimization, development, customization and consulting.<br>
> Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra<br>
> Simplicity is the ultimate sophistication. --   Leonardo da Vinci<br>
> For every complex problem, there is an answer that is clear, simple, and<br>
> wrong." -- H.L. Mencken<br>
><br>
</div></div>> _______________________________________________<br>
> kwlug-disc mailing list<br>
> <a href="mailto:kwlug-disc@kwlug.org">kwlug-disc@kwlug.org</a><br>
> <a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
><br>
<br>
<br>
_______________________________________________<br>
kwlug-disc mailing list<br>
<a href="mailto:kwlug-disc@kwlug.org">kwlug-disc@kwlug.org</a><br>
<a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Khalid M. Baheyeldin<br><a href="http://2bits.com" target="_blank">2bits.com</a>, Inc.<br>Fast Reliable Drupal<br>Drupal optimization, development, customization and consulting.<br>
Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra<br>Simplicity is the ultimate sophistication. --   Leonardo da Vinci<br>For every complex problem, there is an answer that is clear, simple, and wrong." -- H.L. Mencken<br>

</div>