Re: Formatting a mail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14Oct2007 07:21, John Summerfield <debian@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Cameron Simpson wrote:
>> On 13Oct2007 16:22, Paul Ward <pnward@xxxxxxxxxxxxxx> wrote:
>> | Just wanted to say I have figured out a way to do it. as follows,
>> | although a little crude it does give me the result I was after.
>> | | for m in `ls $REPORTS|grep report` ;do
>> | STATS=`cat $m`
>> | echo $STATS >> /tmp/pgstats
>> | echo " " >> /tmp/pgstats # Gives me the formatting
>> | done
>> | mail -s "Printer Reports" pnward@xxxxxxxxxxxxxxxx < /tmp/pgstats
>> | | Thanks for some pointers anyway.
>> Untested cleanup:
>>   for m in "$REPORTS"/*report*
>
> Be aware that in the ,ore general case, this can produce a too-long command 
> line and so fail.

No, it can't. Not for a for loop.

You only hit the limit on exec() calls, which are not involved with shell
builtins.

> A variation using find and xargs is generally sounder.

xargs is a hackish workaround for exec()'s limits.
Necessary, but to be avoided when not needed.

> Also, one needs to beware of paths such as "my documents."

Again, no you don't. Not with a glob. It's perfectly safe, unlike the 
commonly seen:

  for m in `ls blah...`

which is very unsafe, for exactly the reason you fear.

If you pay attention you will see the rest of the script is correctly
quoted, and not subject to the spaces-in-names problem you allude to.

Whereas xargs _is_ subject to space-in-names problems unless you use
finds -print0 and xargs' -0 option, which is terribly special purpose,
and pretty much only works with the find/xargs pair.

>>   do
>>     cat "$m"    # report text

See? Safe.

Please read scripts carefully if you're going to criticise. Criticism is
welcome, if it's valid.

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

..And in all of Babylonia there was wailing and gnashing of teeth, till
the prophets bade the multitudes get a grip on themselves and shape up.
        - Woody Allen

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux