On Tue, Jan 29, 2008 at 06:27:44PM -0500, Andrew Reid wrote:
> On Tuesday 29 January 2008 12:01, Jabka Atu wrote:
> > Good day,..
> >
> >
> > since i can't send find a fast way to send many pictures to Gmail /
> > ISP mail (Quata limit for single mail).
> >
> > I thought it will be fun to do it in one line :
> >
> > find  *.jpg -exec uuencode  '{}' '{}' |  mail [EMAIL PROTECTED] \;

This (but see below for the trailing \; thing and uuencode syntax):

    find  *.jpg -exec uuencode  '{}' '{}' \; |  mail [EMAIL PROTECTED] \;

or this,

    find  *.jpg -exec uuencode  '{} {};' |  mail [EMAIL PROTECTED] \;

ought to work.  For that matter, the bash shell won't mess with the {}
characters, so they don't even need to be quoted.  I'd generally do
it like:

    find  *.jpg -exec uuencode {} {} \; |  mail [EMAIL PROTECTED] \;

> > but this won't work since :
> >
> > find: missing argument to `-exec'
> 
>   I think you're using "find" wrong.  On my (debian "stable") system,
> in a randomly selected directory, I get:
> 
> > # find *.jpg
> > find: *.jpg: No such file or directory
> 
>   ... versus
> 
> > # find . -name "*.jpg"
> > [big list of files]

find is a useful and powerful utility, but it's particular about getting
command line arguments in the way it understands.  Hard to blame it
for that, but the syntax may be confusing; I know it took me a while
to get it figured out (as far as I have) by reading and rereading the
manpage and/or info docs, and maybe looking for something like a Linux
Journal article on the subject.  Don't overlook find -h or find --help,
if that works, as often the 'help' info provided that way is very concise,
if not exhaustive.

It should probably be noted that the syntax details may well vary
between different finds in Linux/Unix distributions, sometimes even
between versions of the same one, but in all cases the installed help
and manpages will (well, should) define the syntax.  If you're using
find with busybox you'll need to look at those docs to see what to do.

I find find very useful, and find's -exec command as well, but someone
always chimes in with how it's "wrong" to use it since it causes find to
create umpteen shell processes, one for each hit, and you really should be
piping find into xargs.  Whatever.  I use xargs a lot too, but I figure
my computer's generally just sitting there spinning its wheels anyway,
and I'm doing it a favor by giving it something to do :-).  I read into
those arguments the assumption that the computer is serving zillions of
web queries or doing other real work, but that's not always the case.

Besides find, don't overlook some of the shell loop constructs or ways
to use subshells.   I'm not sure, but the following might do the same as
what you're doing above:

    for f in *.jpg; do uuencode $f $f; done | mail [EMAIL PROTECTED]

Actually, I now see that you've got \; at the end of the mail command,
so maybe you want to mail each one?  I'm not sure of doing that in find,
and dimly recall fighting and failing with trying to pipe inside a find
-exec construct.  This is easy to do with a shell loop, e.g.,

    for f in *.jpg; do "uuencode $f $f | mail [EMAIL PROTECTED]"; done

(Sigh, for all this I assumed uuencode is running as a filter, which somehow
I doubt, given the two filenames given.  I think you'll want to use a single
argument to get the output to stdout.)

Ken

-- 
Ken Irving, [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to