<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">

<channel>
<title>&#x27;find&#x27; and &#x27;sendmail&#x27; in All Things Unix</title>
<link>http://www.dslreports.com/forum/r18503994</link>
<description></description>
<language>en</language>
<pubDate>Sat, 05 Dec 2009 06:53:48 EDT</pubDate>
<lastBuildDate>Sat, 05 Dec 2009 06:53:48 EDT</lastBuildDate>

<item>
<title>Re: &#x27;find&#x27; and &#x27;sendmail&#x27;</title>
<link>http://www.dslreports.com/forum/remark,18525375</link>
<description><![CDATA[<A HREF="/useremail/u/930878"><b>DprssdIsntFn</b></A> : <div class="bquote"><SMALL>said by  nixen <A HREF="/useremail/u/698757"><IMG SRC="http://i.dslr.net/bb/profile.gif" ALT="See Profile" BORDER=0 WIDTH=16 HEIGHT=11></A> :</SMALL><BR><BR>Why not use mailx instead of trying to figure out sendmail?<br> </DIV>I actually started out with mail(x). On this system, mail(x) calls sendmail to send mail. I got absolutely nowhere with it.<br><br>The problem isn't with sendmail. It's with this version of 'sh'. I've finally tracked the problem down to how 'xarg' and 'exec' are parsed from within a 'sh' script. The parsing is not correct when redirection of a file to standard input is involved. For most cases, the parsing works fine. Just not in this case.<br><br>I'm taking a different approach entirely. Instead of writing just emails to a directory, I'm also writing short, 3-line 'sh' scripts to another directory. Then I select that directory and execute the scripts there.<br><br>Fortunately, this is a relatively low volume application.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,18525375</guid>
<pubDate>Mon, 18 Jun 2007 08:11:50 EDT</pubDate>
</item>

<item>
<title>Re: &#x27;find&#x27; and &#x27;sendmail&#x27;</title>
<link>http://www.dslreports.com/forum/remark,18511676</link>
<description><![CDATA[<A HREF="/useremail/u/698757"><b>nixen</b></A> : Why not use mailx instead of trying to figure out sendmail?]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,18511676</guid>
<pubDate>Fri, 15 Jun 2007 12:52:06 EDT</pubDate>
</item>

<item>
<title>Re: &#x27;find&#x27; and &#x27;sendmail&#x27;</title>
<link>http://www.dslreports.com/forum/remark,18511640</link>
<description><![CDATA[<A HREF="/useremail/u/930878"><b>DprssdIsntFn</b></A> : Thanx for the responses so far. To answer some of the questions:<br><br>These are regular files.<br><br>Here are some sample attempts and corresponding results:<br><br>1} This example works:<br><textarea name="code" class="text" cols=50 rows=10>test.em&#012; &#012;#!/bin/sh&#012;sendmail -t &lt;emails/new/test4&#012;exit&#012;</textarea><!--end code block-->result:<br><textarea name="code" class="text" cols=50 rows=10># ./test.em&#012;#&#012;</textarea><!--end code block-->None of the following example(s) work. What you see here are different combinations of different things I've tried. i.e. one from column A, one from column B ...<br><br>The results below are typical.<br><textarea name="code" class="text" cols=50 rows=10>automaild&#012; &#012;#!/bin/sh&#012; &#012;#&#012;#       Create the list of emails to be processed&#012;#&#012;echo 'create list of emails'&#012;find emails/new/ -type f -print &gt; email.list&#012;cat email.list&#012;echo ' '&#012; &#012;#&#012;#       Create the arguments to be processed by sendmail&#012;#&#012;echo 'create sendmail arguments'&#012;sed 's/ema/\&lt;ema/' email.list &gt; email.send&#012;#sed 's/ema/\sendmail -t &lt;ema/' email.list &gt; email.send&#012;cat email.send&#012;echo ' '&#012; &#012;#&#012;#       Send the email&#012;#&#012;echo 'send email'&#012;#cat email.send | xargs -p -l sendmail -t&#012;cat email.send | ( xargs -p -l sendmail -t )&#012;#cat email.send | xargs -p -l&#012;#cat email.send | exec {}  \;&#012;echo ' '&#012; &#012;#&#012;#       Create the arguments to be processed by mv&#012;#&#012;echo 'create mv arguments'&#012;sed 's/\(&#91;^ &#93;&#91;^ &#93;*\)/\1 \1/' email.list &gt; email.temp1&#012;echo ' '&#012;sed 's/new/sent/g' email.temp1 &gt; email.temp2&#012;echo ' '&#012;sed 's/sent/new/' email.temp2 &gt; email.mv&#012;cat email.mv&#012;echo ' '&#012; &#012;#&#012;#       Move the email to the sent directory&#012;#&#012;#cat email.mv | xargs -l mv&#012;</textarea><!--end code block--><br>Results part 1. Here, I've not answered 'y' to the 'xarg' prompts. This is just to show that the command to be executed is properly formed as in the working example above.<br><textarea name="code" class="text" cols=50 rows=10># ./automaild&#012;create list of emails&#012;emails/new/test1&#012;emails/new/test2&#012;emails/new/test3&#012;emails/new/test4&#012; &#012;create sendmail arguments&#012;sendmail -t &lt;emails/new/test1&#012;sendmail -t &lt;emails/new/test2&#012;sendmail -t &lt;emails/new/test3&#012;sendmail -t &lt;emails/new/test4&#012; &#012;send email&#012;sendmail -t &lt;emails/new/test1 ?...&#012;sendmail -t &lt;emails/new/test2 ?...&#012;sendmail -t &lt;emails/new/test3 ?...&#012;sendmail -t &lt;emails/new/test4 ?...&#012; &#012;create mv arguments&#012; &#012;emails/new/test1 emails/sent/test1&#012;emails/new/test2 emails/sent/test2&#012;emails/new/test3 emails/sent/test3&#012;emails/new/test4 emails/sent/test4&#012; &#012;#&#012;</textarea><!--end code block-->This is a snip of actual results.<br><textarea name="code" class="text" cols=50 rows=10>send email&#012;sendmail -t &lt;emails/new/test1 ?...y&#012;&lt;emails/new/test1... Unbalanced '&lt;'&#012;&lt;emails/new/test1... User unknown&#012;Saving message in dead.letter&#012;dead.letter: line 0: &lt;emails/new/test1... Unbalanced '&lt;'&#012;dead.letter: line 0: &lt;emails/new/test1... Unbalanced '&lt;'&#012;</textarea><!--end code block-->The problem I had with the automatic insertion of the space between '' and 'email/file' I got around through the use of sed and temporary files.<br><br>If I execute the sendmail command directly in a script, it works fine. If I attempt to use either 'exec' or 'xargs', it fails.<br><br>This version of the DG-UX OS was last updated in 1998. This box was installed in 1994. I really, really don't like working with antique OSes!<br><br>Ugh!<br><br>Any more thoughts or ideas?<br>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,18511640</guid>
<pubDate>Fri, 15 Jun 2007 12:45:02 EDT</pubDate>
</item>

<item>
<title>Re: &#x27;find&#x27; and &#x27;sendmail&#x27;</title>
<link>http://www.dslreports.com/forum/remark,18506867</link>
<description><![CDATA[<A HREF="/useremail/u/698757"><b>nixen</b></A> : Umm... are these queue files or regular text files you're looking to mail. If the former, why not simply invoke sendmail with the QueueDirectory option and the "run queue now" option?<br><SMALL>--<br>Everyday, thousands of new cars are delivered to their new owners with poorly-selected radio station presets.</SMALL>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,18506867</guid>
<pubDate>Thu, 14 Jun 2007 16:51:38 EDT</pubDate>
</item>

<item>
<title>Re: &#x27;find&#x27; and &#x27;sendmail&#x27;</title>
<link>http://www.dslreports.com/forum/remark,18504849</link>
<description><![CDATA[<A HREF="/useremail/u/1070900"><b>nwrickert</b></A> : You are correct.  The space is a bogus issue.<br><br>I think the problem here is that "&lt;" is a shell meta-character, but "find" is passing that directly to sendmail, bypassing the shell.  So there is nothing to interpret "&lt;" as file redirection.<br><br>Simplest would be to write a short shell script to mail one file, and then use that shell script as command that is run by "find ... -exec".<br><SMALL>--<br>AT&T dsl; Westell 2200 modem/router; SuSE 10.1; firefox 2.0.0.4</SMALL>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,18504849</guid>
<pubDate>Thu, 14 Jun 2007 11:37:10 EDT</pubDate>
</item>

<item>
<title>Re: &#x27;find&#x27; and &#x27;sendmail&#x27;</title>
<link>http://www.dslreports.com/forum/remark,18504720</link>
<description><![CDATA[<A HREF="/useremail/u/644121"><b>PetePuma</b></A> : <div class="bquote"><SMALL>said by  DprssdIsntFn <A HREF="/useremail/u/930878"><IMG SRC="http://i.dslr.net/bb/profile.gif" ALT="See Profile" BORDER=0 WIDTH=16 HEIGHT=11></A> :</SMALL><BR><BR>sendmail requires that there be no space between angle bracket and the expanded argument. e.g. <br><textarea name="code" class="text" cols=50 rows=10>sendmail -t &lt;emails/new/test1&#012;</textarea><!--end code block--><br> </DIV>I'm curious to see what other folks say.  However I can't see why Sendmail would have any visibility into what the shell does in terms of redirection.  Are you sure the space is the only problem?<br>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,18504720</guid>
<pubDate>Thu, 14 Jun 2007 11:09:43 EDT</pubDate>
</item>

<item>
<title>&#x27;find&#x27; and &#x27;sendmail&#x27;</title>
<link>http://www.dslreports.com/forum/remark,18503994</link>
<description><![CDATA[<A HREF="/useremail/u/930878"><b>DprssdIsntFn</b></A> : I'm working on a very old version of DG-UX (1994) using the Bourne shell: 'sh'<br><br>The ultimate goal is to create a daemon which will invoke sendmail (v8.4.x) to send all the emails in a directory.<br><br>The version of 'sh' is quite primitive. I can manually invoke sendmail using the command:<br><textarea name="code" class="text" cols=50 rows=10>sendmail -t &lt;emails/new/email001&#012;</textarea><!--end code block-->I had thought that some variation such as:<br><textarea name="code" class="text" cols=50 rows=10>find emails/new -type f -exec sendmail -t \&lt; {} \;&#012;</textarea><!--end code block-->would find and send all the emails in the directory. However, I get some variation on<br><textarea name="code" class="text" cols=50 rows=10>&lt;... Unbalanced '&lt;'&#012;&lt;... User unknown&#012;</textarea><!--end code block-->no matter what I try.<br><br>Could someone please let me know what I'm doing wrong or suggest alternative ways of doing the same thing?<br><br>Thanx!!<br><br><I><B>edit</B></I><br><br>The problem is that I always end up with a space between angle bracket and the expansion of '{}' like so:<br><textarea name="code" class="text" cols=50 rows=10>find emails/new -type f -print | xargs -p -l sendmail -t '&lt;'&#012;sendmail -t &lt; emails/new/test1 ?...&#012;</textarea><!--end code block-->sendmail requires that there be no space between angle bracket and the expanded argument. e.g. <br><textarea name="code" class="text" cols=50 rows=10>sendmail -t &lt;emails/new/test1&#012;</textarea><!--end code block--><br>Thoughts? Advice?<br><br>I'm currently looking at building an interim file and using sed on it and then pulling up each resulting line as the full command to be executed but ... that would certainly not be elegant!<br>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/remark,18503994</guid>
<pubDate>Thu, 14 Jun 2007 08:26:31 EDT</pubDate>
</item>

</channel>
</rss>
