My scripting talent is sadly failing...

Glenn Steen glenn.steen at gmail.com
Tue Jan 23 14:21:27 CET 2007


On 23/01/07, Nigel Kendrick <support-lists at petdoctors.co.uk> wrote:
> Hi Folks,
>
> I have put together the following one-liner to re-submit all emails sent to
> me from an archive folder - it works EXCEPT that the 'echo/cut' command is
> not removing the file extension from the file name and so the emails are not
> processed in the queue. Would someone kindly have a look and educate me!!
>
> grep -l 'To: <nigel.kendrick' * | xargs -t -i bash -c "chmod 700 {} ; cp {}
> /var/spool/postfix/hold/`echo {} | cut -d . -f 1` "
>
> Many thanks
>
> Nigel Kendrick
>
A bit off-topic, but what the...:-).
You're not that far off. Observe:
# echo 123456789.12345|xargs -t -i bash -c "echo chmod 700 {} ; echo
cp {} `echo {} | cut -d . -f1` "
bash -c echo chmod 700 123456789.12345 ; echo cp 123456789.12345
123456789.12345
chmod 700 123456789.12345
cp 123456789.12345 123456789.12345
# echo 123456789.12345|xargs -t -i bash -c 'echo chmod 700 {} ; echo
cp {} `echo {} | cut -d . -f1` '
bash -c echo chmod 700 123456789.12345 ; echo cp 123456789.12345 `echo
123456789.12345 | cut -d . -f1`
chmod 700 123456789.12345
cp 123456789.12345 123456789
#

Problem is _which_ shell interpretes the quoted stuff or not. With
single quotes you make sure that the one called by xargs is the one.

Now, you need make sure those queue files are owned by your PF user
too, else they will just sit there:-).

Cheers
-- 
-- Glenn
email: glenn < dot > steen < at > gmail < dot > com
work: glenn < dot > steen < at > ap1 < dot > se


More information about the MailScanner mailing list